How to add Custom Dimensions to UTMs

Setting Google Analytics Custom Dimensions through a URL

UTMs are an amazing source of information for Google Analytics, but sometimes you need more. In this article HammaJack co-founder, Jacob Moran, outlines how to set Custom Dimensions in Google Analytics using UTMs and Google Tag Manager.

The scenario

So, let’s say that you have a site that has different Personas. You want to know how these Personas use your site, as well as their propensity to convert. As part of your Digital Strategy, you are doing a lot of Digital Marketing to try and drive more people to the site. This Digital Marketing focuses on each of your Personas, so you want to tag your marketing campaigns by Persona and pass this information through to Google Analytics. This could look something like the following;

  1. Facebook Ad targets a “Hardcore Driver” Persona

  2. A user clicks the ad and is taken to the site

  3. The user sees some content and signs up to the newsletter

Now through the beauty of UTMs, you know that this user came from a paid ad on Facebook, but you also want to know that they were a Hardcore Driver. How can you do this?

While you could use one of the standard UTM fields (such as utm_term or utm_content), the best bet is to use a custom UTM string that links to a Custom Dimension.

If you aren’t sure what UTMs are, I recommend reading our non-technical guide to UTMs before continuing.

How to set a Custom Dimension with Google Tag Manager and UTMs

Now there are three parts to this;

  1. Giving the UTM to the site

  2. Scraping the UTM with GTM 

  3. Sending it to Google Analytics.

Setting the UTM

Setting the UTM is fairly straightforward but does require some knowledge of UTMs. 

First things first, UTMs aren’t exclusive to Google Analytics. UTMs are just query strings that Google Analytics has been conditioned to understand. Query strings are used all across the web, for a variety of reasons, but the basic idea is that a query string allows a website (or browser) to get more information than just the URL, which it can then take and use for some purpose. 

Knowing this, it hopefully makes sense that you do not need to stick to the standard UTMs when providing information to Google Analytics (or any other system). You can provide whatever information you want.

For example, some use cases of what query strings (UTMs) can include are;

  • The weather when the UTM was generated

  • A user’s level of subscription

  • A user’s choice of product or package

  • Personas

With Personas, all that a marketer needs to do is set a query string variable of utm_persona on the URL and then ask the Data Engineer to pick it up. 

This could look like the following;

If the above looks too ugly you could always shorten your URLs with short URLs. 

A few tips for creating the UTM;

  • Ensure the naming convention makes sense 

  • Ensure the naming convention is scalable

  • Make sure you use “_” instead of spaces

  • Be careful with Upper vs. Lowercase as any difference will matter

Scraping the UTM from URL with Google Tag Manager

The next step is scraping the query string using GTM.

To do this, all you need to do is create a User-Defined Variable in GTM that defines the UTM value, which matches utm_ persona.

Creating a Variable in GTM.png

Once this is done, if you preview your container (with the UTM) you should see the variable being declared.

UTM Variable in GTM.png

Declare the Persona Custom Dimension in Google Analytics

Next you need to prepare Google Analytics to accept the information. To do this, you need to create the Custom Dimension in Google Analytics.

Google Analytics Custom Dimensions.png

Sending the Custom Dimension Value to Google Analytics

Once the persona has been declared in GA and GTM, you just need to update your Google Analytics page tag to send the information as a Custom Dimension. To do this, go to your Google Analytics pageview tag in GTM and set the corresponding Custom Dimension to the variable that you set up in GTM earlier.

Google Analytics Tag in Google Tag Manaager with Fields Set.png

Once this is done, publish it and then you should see it being sent to Google Analytics.

Google Analytics Tag in Google Tag Manager with Custom Dimensions.png

After this you should see the data coming through into you Google Analytics reporting. This can take up to an hour in some cases (as it doesn’t turn up in the real-time reporting).

Most important point

Whilst UTMs alone provide valuable information to Google Analytics, inserting a custom dimension that defines your target Persona allows you to learn even more about them. By learning which Personas are engaging with your ads, you’ll be much more effective with your Digital Marketing and will be able to send the right message to the right audience.