In today’s blog post, I will provide a general guide to using the Google Analytics Tool in Alteryx. In addition, I discuss how and why I used a batch macro to download Google Analytics data as well as common error messages encountered using this tool.
Google Analytics Interface in Alteryx
I thought the help files here were useful as a guide. The first step is to login using your google analytics credentials. I recommend using the offline sign-in method. This is how it looks like on sign-in:
In the next page, a user can then select Accounts, Web Properties and Profiles. These profiles or views are linked to unique table ID associated with the data query. A date range can then be selected for metrics and dimensions to be downloaded. The screen to select metrics and goals look like this:
Google Analytics only allows certain combinations of metrics and dimensions. This website can help when trying to determine if groups of metrics and dimensions can be selected together. I found it useful to start with selecting the date dimension and then any important first metric. Incompatible metrics are greyed out as you start selecting. The Final page on the Google Analytics tool configuration view is a summary of the user choices. The tool is then ready for use.
Why Use a Batch Macro?
To download a limited subset of the data, a batch macro is not useful. However, automating the download process is useful for larger data sets. Other use cases include when downloading discontinuous dates and to avoid situations where Google Analytics API is limiting what can be downloaded.
I created a simple batch macro with parameter controlled start and end dates. These Parameter Control tools are set to update the corresponding fields (“startDatePicker” and “endDatePicker”) inside the Google Analytics tool. I included a snapshot of my batch macro below:
The start and end date can then be supplied to the macro from an outside source. In this case, I created a short workflow to generate all the dates up to the end date given a start date and the number of days to end date. I used a combination of the Generate Rows tool as well as the “DateTimeAdd” function in the Formula tool. I have included this section of my workflow below:
With everything set up, I can run the workflow. This proceeds to download the data I requested one day at a time. You should see this message appear in the Results View/Window in Alteryx:
Info: Macro GA Download (30): Record #1: Tool #1: Tool #1: Google API: Authorization Token refreshed
This will then be followed by record 2 and so on. Conveniently, the tool also tells you how many iterations were run.
What if I Get Errors while Downloading?
The good news is that this doesn’t always mean having to re-run the workflow. I have found that the following “error” message is actually followed by an automatic attempt (by the Google Analytics tool) to re-download the data:
As aforementioned, Google Analytics managed to download the records with the above error message by re-attempting the download. However, some error messages do not result in a re-download attempt:
Unfortunately, these mean that a re-run of the workflow is required. Occasionally, the following message also appears:
I discovered that this happens for high user sessions for a particular website. My advice would be to re-download with less granular data fields. For example, I would try to download at a date level rather than by hour and date.
That’s all from me for this blog. I hope this blog post has helped you more efficiently download Google Analytics data.
Featured Image by Luke Chesser on Unsplash