Search code examples
google-analyticsgoogle-analytics-apigoogle-analytics-4

How to handle pagination in ADF loop for Google Analytics 4 v1beta API without nextPageToken value in response?


I am trying to get data from the new version of Google Analytics 4 version 1 beta.

In the old version, I could use pagination to get all the data for a large date range. So, in Azure Data Factory I had a foreach loop activity, where the call to Google Analytics API was made until the nextPageToken value was 0.

Now I am trying to apply the same logic on the new version: https://analyticsdata.googleapis.com/v1beta/properties/**propertyId**:runReport I have read that I can use the offset for this problem, but I do not get the value of the nextPageToken in the response of the new version API.

Can someone please help me with this issue? Or more exactly, how can I handle pagination issue in ADF foreach loop for the new version of Google Analytics GA4 version 1 beta

Best regards!

Tried to get the nextPageToken value on the response body of the new Google Analytics API version 1 beta. I do not get the nextPageToken at all.


Solution

  • So, I managed to solve the pagination of Google Analytics 4 version 1beta in ADF pipeline. I have three set variable activities, set offset to 0, set limit to 100 000 and set total rows received to 0. Then I added an until activity with condition, until total rows received and row count (from the response) are the same. Inside the Until activity, I update these 3 variables.

    Hope this solution will help someone :)