Custom Dimensions & Metrics In GTM

Deepak Garg
5 min readFeb 27, 2022

I started with Intermediate Google Tag Manager on CXL, and my tutor is Chris Mercer from measurementmarketing.io.

Introduction to the Course:

During the lesson, we discussed the custom dimensions and how to set up custom dimensions in analytics using Tag manager. From time to time, using platforms like Google Analytics You’re going to want to get very specific questions. And sometimes we need very specific information in order to answer those questions. Information that Google Analytics doesn’t provide on it’s own and that we must customize. Fortunately, Google Tag Manager helps make this easy.

Understanding Customer Dimensions & Metrics

So Why exactly we need custom dimensions?

Well, Google Analytics already provides a ton of data that includes browser size, page views and event more specific things that can be setup using events. But sometimes event aren’t just enough. Sometimes we actually want to have the completely separate data . That separate data can be metrics or any other useful data. Here we took the example of the Affiliate network. For that we will be using Google Analytics setting variables. In the case of Affiliate Network the possible dimensions can be knowing about partner traffic or affiliate traffic , the name of the affiliate network and much more. Many times when we are having traffic promoted to a certain group or buy a certain group there is an affiliate ID. And it might be something, aff id equals 1234. And so you’ve got aff id equals 1234and they land on the sales page and then that sets a cookie with the affiliate tracking system and we’re able to tell who gets paid for what based upon sales.That’s all great within the affiliate tracking system.However wouldn’t it be a great idea if we could also get the value of this aff id in this case 1234 into Google Analytics?W ell we can and when it’s in Google Analytics When it’s being stored in the Google Analytics We can build reports out of it.And that’s what is the difference between storing this as an event somewhere and actually storing it in a dimension so that we can actually build a report from it.So we’re going to talk about exactly how to do that.We’re going to go to the back end of Google Analytics

In the analytics at the Property level, we have Custom Dimension and Metrics. Now just for a note here dimensions are just the things that we sort by in Google Analytics and the metrics are just the numbers. The metrics are just the numbers in those tables. So depending which one we want to use.They both are exactly the same. Here in example we used Dimensions to demonstrate how it works.

Now in order to create a new custom dimension, click on Add Custom Dimension, Add a Name to it. Now in the Scope we have different metrics that we may want to pull, it includes Hit, Sessions, User and Product.

Now again this is where you choose the scope and product is really just for anything related to ecommerce. So maybe we want to do a custom metric for maybe profit or net profit. We could do that under product scope.

Hit scope is each individual hit would be associated with this particular under custom dimension but if there’s a hit that does not have that custom dimension it wouldn’t carry across.

Session is it’s associate all hits within just that session even if it’s on the very last hit of the session.All the other hits would actually get this. And then user is associated to the user.So as soon as it’s available it gets to associate to the session and then all future sessions. So that’s sort of how this works with custom dimensions in particular scope.

On the other hand, Custom Metrics has index number and we will have to add a integer value for a particular hit. That can be a number, price or anything integer value.

Now once we are done in the Google Analytics Configuration, we wil need to configure the Google Analytics Variable and add a custom dimension to it. So go to the Tag Manager then variable, find your Google Analytics variable and click on edit.

Scroll down and you will find Custom dimensions, in the custom dimensions add the index number that can be found in your Google analytics custom dimension section and now the parameter, so for the parameter you will need to create a custom variable depending on your requirements.

In the example we used the Custom Variable as URL that has a query parameter affid. Now we can test it and everything will work. But if there is no value it will show as undefined.

If there is no value and its undefined and it doesn’t have any sort of single quotes around it it’s just plain like this undefined just like this.When it looks like this essentially that’s analytics seeing that there is truly nothing there and it’s just going to ignore it.

It’s not going to try to record anything,it’s not going to try to put the word undefined in there,it’s not going to say not set, it’s just going to ignore it.’ Cause it knows that it’s just empty.That’s basically empty.That’s how analytics is just going to take that.So whenever you see this stuff that says dimension one undefined, dimension two undefined.Pull this over so it’s a little easier to read.When you see this again without the single quotes around it.

Again if it was single quotes it would be treated as a word as a string and actually would say undefined in analytics.But in this case it’s just going to be ignored.Analytics is going to be like okay cool.There was no dimension so I’m not going to associate anything for this particular hit.Which is why again we want to use the Google Analytics Settings variable cause it’s kind of the best for both worlds.

Lesson Resources:

--

--