Google Tag Manager Custom Dimensions & Metrics

This article will deep dive into how to send Custom Dimensions and Metrics to Google Analytics using Google Tag Manager.

janet wong
6 min readDec 10, 2021

Did you know that Google Tag Manager can create custom dimensions and metrics? This is a powerful feature because marketers can now track how their specific marketing efforts are performing in Google Analytics from time to time. This blog post will show you how to use the Google Analytics Setting variable to create custom dimensions and metrics in your Google Tag Manager account.

Understanding custom dimensions and metrics

Let's start with the simple question — Why exactly would you need this?

We all know that Google Analytics does a great job collecting a ton of data, enabling marketers to track specific behaviours. But sometimes, the events aren't enough, and you would need a completely separate set of dimensions and metrics in order to answer your questions.

So, what's an example of a possible dimension? The affiliate or partner traffic could be a great example. When you have your traffic promoted to or by a specific group, an affiliate ID is generated. This link will direct to your sales landing page, and then that sets a cookie with the affiliate tracking systems, which you're able to tell who gets paid for what based upon sales.

https:// www.digitalmarketinglikepro/?affid=1234/

However, wouldn't it be a great idea if we could also get the value of this affiliate ID, i.e. 1234, into Google Analytics to build the report out of it?

And this is the major difference in storing between an event and dimensions.

Setting-Up Custom Dimensions & Metrics

First, head to your GA settings. Under the property level, you will find the custom definitions with two choices — custom dimensions and metrics. Dimensions are just things you sort by in GA, and the metrics are just the numbers in those tables. And, it all depends on which one you want to use.

Let's go for the dimension for now. Click on +New Custom Dimension

Create New Custom Dimension

Here you will add the name of your custom dimension and give the option for the scope type: Hit, Session, User and Product.

  • Hit scope is each individual hit associated with particular under custom dimension, but if there's a hit that does not have that custom dimension, it won't carry across.
  • Session scope associates all hits within just that session, even if it's on the very last hit of the session. All the other hits would get this.
  • User scope is associated with the user. So as soon as it's available, it gets to associate with the session and then all future sessions. So that's sort of how this works with custom dimensions in a particular scope.
  • Product scope is for anything E-commercial related, and you can do that under the product scope to track the profit and net profit with custom metrics.
Add Custom Dimension

Once you have done with all selections and created the custom dimension, you will see the following code, which we will skip at the moment because we will use GTM to assist us with the code.

Remember that index numbers are essential parts that you will use in the GTM.

The above process will be the same for setting the custom metrics, and the only difference is that metrics refer to the number you may need to define the formatting type and give the value input.

Create custom metrics

We will be focusing on custom dimensions, so you would need to access your GTM account and go into the variables to go ahead with the setup.

We will use GA setting variables ( global variable) over time. Still, if you can recall, the issue experienced in the e-commerce tracking were changing the global variable setting will affect the entire GA tags, and your GA tags are reporting all the Ecommerce at all times. As for the solution, you had to go into the individual tag to report Ecommerce and overriding settings restricted this.

Still, we will use global variables to configure the custom dimension.

If you open up your GAS variable and click a "field to set" settings, more settings will show up, and you will see the custom dimensions.

You can find your index from GA. In this case, the affiliate ID is index 1, and the dimension value would be affid itself. We are not taking the ID, .i.e. 1234, because this is just a label, and if we fill in the ID, it would be hardcoded all the time. So you are grabbing the values from the parameters in the URL, and hence you would need to create a URL variable for the dimension value.

To do so, click on + sign and create a new variable as follow:

Create a new URL variable for dimension value for affiliate ID.

Bear in mind to put the query in lower case since GTM is case sensitive.

And now, you can go ahead with the 2nd, 3rd index ( customer avatar and login state). In the same step, you will create a new variable for the dimension value, and here we have URL- ca for the customer avatar.

Create a new URL variable for dimension value for customer avatar.

You may not have the custom dimension coming from the URL but store it in the data layer—for example, the login state. And using GTM from the WordPress plugin is a great way to see the info in the data layer. So for your login state, instead of using URL for the variable, you can use data layer variable to pull visitor log in state out. This variable name won't go all lowercase because GTM is case sensitive by default, and you need to follow what's in the data layer.

Create a new Data Layer variable for dimension value for Login State.

This is all your setup in the custom dimension. Your custom metrics set up will essentially be the exact steps; for example, you may have the netProfilt variable for the custom metrics. And, there will also be the case where you don't need the custom metrics.

You can set up the custom metrics if required.

So now, you can go ahead, click on save, and this is complete.

*Note that you may want to pull up your GA debugger extension to test it out.

If you aren't sure where to use the custom dimension, the following link will serve you as a good guide for different scenarios and help you understand them better!

Lesson Resources:



janet wong

“Everything is theoretically impossible, until it is done.” Robert A. Heinlein.