The out-of-the-box dimensions and metrics on Analytics platforms provide a lot of useful information in understanding visitors’ behaviour. However, it is often found that standard reports cannot provide enough insights and we need to export data out for some further analysis. It is more than often that one of the key information is missing from the list of dimensions for export in Google Analytics, visitor ID. Without a visitor ID, we are not able to identify the web visit behaviour of individual visitors, even anonymously.
Google Analytics, just like other analytics platforms, uses a cookie to identify individual visitors at the browser level. It is just Google’s decision not to provide the visitor ID for analytics users. Therefore, we need to capture the visitor ID and store it as a custom dimension, one of the twenty precious custom dimensions available in the free Google Analytics.
Google has documents on how to configure custom dimensions in Google Analytics and separate documents on how to configure custom dimension tracking in Google Tag Manager. Those documents are a bit disconnected so here is a walkthrough on how to do visitor ID tracking from end to end.
The first step is of course setting up the custom dimension in Google Analytics. “Custom Dimensions” are available under “Custom Definitions” at the property level in the Google Analytics account. Go there for the list of existing custom dimensions as follows:
The above shows one custom dimension, Visitor ID Cookies, which is the custom dimension we are going to create. To start, click on the “New Custom Dimension” button on the following screen:
The screen is straightforward for the name, scope, and status of the dimension, just to be reminded that the visitor ID custom dimension should be at “User” scope since the ID would not be changed for a visitor. After creating the custom dimension and going back to the list of custom dimensions, mark down the index of the custom dimension as it is required in setting up the tracking in Google Tag Manager.
The next step is setting up Google Tag Manager. Direct implementation is not covered in this post as GTM is the preferred way of managing tags on websites.
In GTM, we first need a variable to retrieve the visitor ID from browser cookies. Go to the “Variables” in the GTM container and click on the New button under “User-Defined Variables”.
Update the variable from “Untitled Variable” to “GA Visitor Cookie” or your preferred name then select “1st-Party Cookie” as the type. Finally, enter “_ga” as the “Cookie Name” and create the variable.
After we get the visitor ID cookie into the variable, we need to track it with Google Analytics tracking. When using Google Analytics with GTM, a tag should be fired on all pages for the most fundament web traffic tracking. The visitor ID tracking will reuse that tag. Go to that tag in GTM and under the “Configure Tag” section, expand the “More settings” then “Custom Dimensions” and add a custom dimension.
The Index should be the number marked down from the Google Analytics setting above and select the “GA Visitor Cookie” variable from the dropdown list for “Dimension Value”. Finally, we save the tag and publish it to production.
Setting up a custom dimension for visitor ID is straightforward. It is also a must-have for all Google Analytics accounts until one day Google decided to add the visitor ID as a standard item in the GA interface and reporting API.
Leave a Reply