R You Interested in Auditing Your Google Analytics Data Collection?
One of the benefits of programming with data — with a platform like R — is being able to get a computer to run through mind-numbing and tedious, but useful, tasks. A use case I’ve run into on several occasions has to do with core customizations in Google Analytics:
- Which custom dimensions, custom metrics, and goals exist, but are not recording any data, or are recording very little data?
- Are there naming inconsistencies in the values populating the custom dimensions?
While custom metrics and goals are relatively easy to eyeball within the Google Analytics web interface, if you have a lot of custom dimensions, then, to truly assess them, you need to build one custom report for each custom dimension.
And, for all three of these, looking at more than a handful of views can get pretty mind-numbing and tedious.
R to the rescue! I developed a script that, as an input, takes a list of Google Analytics view IDs. The script then cycles through all of the views in the list and returns three things for each view:
- A list of all of the active custom dimensions in the view, including the top 5 values based on hits
- A list of all of the active custom metrics in the view and the total for each metric
- A list of all of the active goals in the view and the number of conversions for the goal
The output is an Excel file:
- A worksheet that lists all of the views included in the assessment
- A worksheet that lists all of the values checked — custom dimensions, custom metrics, and goals across all views
- A worksheet for each included view that lists just the custom dimensions, custom metrics, and goals for that view
The code is posted as an RNotebook and is reasonably well structured and commented (even the inefficiencies in it are pretty clearly called out in the comments). It’s available — along with instructions on how to use it — on github:
I actually developed a similar tool for Adobe Analytics a year ago, but that was still relatively early days for me R-wise. It works… but it’s now due for a pretty big overhaul/rewrite.
Happy scripting!