I’ve spent a lot of time talking and writing about how to improve the accuracy of your Google Analytics data, especially when using Google Tag Manager. I also ran over and over (and carried on)
customTaskThis makes adding metadata to Google Analytics results sent from your website a breeze.
In this article, I will present a simple way to add another level of detail to your GA results, using
customTask as the method of choice. The piece of data we will be adding is hit type from the blow (eg View pageAnd Event, And timing) which, for some ridiculous reason, is not a default dimension available in Google Analytics reports.
Simmer . Newsletter
Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava right in your inbox!
Tip 80: Add the result type as a custom component
adding hit type As a custom dimension is fairly easy, because it is a default field available in the form object
customTask It automatically receives it as a parameter when it is executed.
So, to get started, create a new custom dimension on the results domain in your Google Analytics site settings. give him a name blow type. Make a note of a file index number assigned to the new dimension.
customTask Worker). Add the following code inside:
function() var hitTypeIndex = 2; return function(model) model.set('dimension' + hitTypeIndex, model.get('hitType')); ;
hitTypeIndex variable value of
2 In the example whatever index number is for the custom component.
Finally, add this variable to everyone Your Google Analytics tags in More settings / Fields to be set. It’s even easier if you add it to the Google Analytics settings variable (you’re using one, right?). The field name must be
Now, each tag containing this set of fields will automatically send the result type to Google Analytics as part of the results payload.
You can check that this setting is working using the Google Analytics Debugger browser extension, and check that the result type is being sent with the correct Custom Dimension parameter (
&cdX, where X is the index number).
If you can see this parameter, you will know that everything should work as intended.
And What can you do with this data, You ask? Well, the most useful app (in my opinion) is Slides. You can create advanced segments like the one in the title image for this article to find specific sequences for different hit types, such as sessions in which an event preceded the pageview hit.
Or you can pull the data with the Reporting API, and use the new version blow type Custom dimension as an additional level of detail. This is especially useful when combined with dimensions such as results timestamp, session ID, and a variety of browsing behavior dimensions presented in this article.
Let me know in the comments if you can think of other uses for this data! Always happy to delegate the actual Analytics Work for people wiser than me.