Icon

Google Analytics 4 and Loops

There has been no title set for this workflow's metadata.

This workflow showcases the capabilities of Google Analytics 4 in conjunction with the KNIME Analytics Platform. You can easily download and run the workflow directly in your KNIME installation. We recommend that you use the latest version of the KNIME Analytics Platform for optimal performance.

This example demonstrates how to use loop nodes to extract data from the Google Analytics Query node. Suppose you have a large website with numerous landing pages. In that case, you may need to use loops to query data from Google Analytics for the following reasons: to avoid sampling, retrieve all data exceeding the 100,000 rows limit, and create periodic backups of your data.

After mentioning the above, we can return to the workflow. As you may notice, the workflow nodes are currently not executed (indicated by the red light) because you need to authenticate through your Google account via the Google Authenticator node. Select the node and refer to its description on the left side panel for instructions on storing your credentials within the workflow.

By default, the credentials are stored in memory, meaning you must authenticate again when you reset the node or close the workflow.
Once authenticated, you can connect to the "Google Analytics Connector" node.

We use the "Date&Time Configuration" nodes to select the desired time range for data extraction. The output table of the Create "Date&Time Range" node should display one column with all the dates within the selected range.

Then we use the "Table Row To Variable Loop Start" to take each date row and set it as a flow variable in the Google Analytics Query node. Thus, we perform a separate query for each day within our time range.

The "Loop End" node output is a table that contains all the information extracted in each iteration. This table is then passed to a "CSV Writer" node to back up our data as a CSV file. Additionally, we can connect it to a DB node to store the data in a data warehouse.


URL: GA4 Report pagination - Docs https://developers.google.com/analytics/devguides/reporting/data/v1/basics?hl=en#pagination
URL: GA4 Data Retention - Docs https://support.google.com/analytics/answer/7667196?hl=en
URL: GA Sampling - Docs https://support.google.com/analytics/answer/13331292?hl=en

Nodes

Extensions

Links