While using Google Analytics more frequently, you will need to find specific answers to specific questions every once in a while. Sometimes these answers require going beyond the common information available in GA. To do so you will probably need to customize some features which, fortunately, can be easily done using Google Tag Manager.

Today’s objectives:
Customizing Google Analytic’s Dimensions and Metrics
Taking small deep dive into the Google Analytics Settings Variable

Reasons For Using Customer Dimensions & Metrics

Let’s begin by answering simple questions: why would you need Custom Dimensions and Metrics?
As discussed in the 3 essential tools you should focus on for digitial analytics, Google Analytics collects a vast amount of data very well. You can track a range of behaviors, the bowser’s size, and page views. However, even events may not be enough. There may be times where you need completely different dimensions or metrics to conduct your analysis.
What if you have an affiliate or partner traffic? Often times there is an affiliate ID that is attached to your traffic that is being promoted to a certain group or by a certain group. These are cases where you’d want to have a custom dimension so that you could have specific reports and conduct further analysis. You will need the Google Analytics Settings Variable (GAS) to set this up.

Create your custom Dimension or Metric in Google Analytics

First, go to your Admin section > Property Settings >> Custom Dimensions

Create a New Custom Dimension:

For our example, we’ll select a Hit Scope:

Then go to Google Tag Manager.
Under User-Defined Variables, choose your Google Analytics Settings Variable (GAS).

Go to the Custom Dimension.
For index, put the same number as you have in GA

What do we put for Dimension Value in GTM (next to index)?
We can put the affiliate link parameter that is added to our link.

What do we use in GTM in order to extract values from a link ???
You use the URL Variable.

So select the URL Variable:

Select “QUERY” for “Component Type”.
Type your Query Key, for us it’s “affid” as you can see here :
So whatever comes after the = sign will be captured as the Query key value (which is 1234).

Rename your variable :

Now, this is what we have :

Note: In GTM, ask yourself where is the value I’m looking for lacted ?
Then you can start figuring out what you need from GTM in order to extract this value or track it.
For example, if my info is in a URL (like the example above), you will then need a URL VARIABLE.

the Let’s continue and add the other dimensions:

The third one is for users that are logged in.

Question is, where would I access that information?
Because it’s not shown in the URL here.

This information is shown in the Data Layer Variable.

How do I know?
How come this “logged-in” information is in the data layer ?
Because in our case, we’ve used the Google Tag Manager plugin for WordPress which does that once we select the option.

Plugin in WordPress

In the Data Layer, you can see how the information that has been pushed appears:

Go to the Data Layer in GTM’s Preview Mode on your web page

So now what do we need to pull that out so that GTM can use it to send it to GA?
We will need the Data Layer Variable.

Select the folder with the + sign:

Select Built-Ins

Write the Data Layer Variable Name as it is in the Data Layer

You can see that it is written with the same camel case as seen in the data layer in GTM Preview Mode on our web page (in the black frame)

Remember it’s case sensitive.

Rename it :

Refresh the Preview Mode and your Web Page

Use the Debugger extension on your Web Page.

Refresher: Why do we use the Debugger extension?
Usually, we use the Real Time Report in GA to ensure that our setup is being processed.
But GA’s Real Time Report tends to work for default setting and not for Custom Dimensions and Metrics. Real time reports will delay and can take time to display information.
This is why Google Tag Manager’s Preview Mode and the Debugger extension help to see this information right away.

You can add much more info: like t-shirt size, or t-shirt color

Common Questions

Because we’re using the GA Settings Variable, our custom dimensions/metrics are being reported multiples times during each page view, for each hit and events it gets reported. When we did Enhanced Ecommerce (EEC) in the previous lesson, we removed the EEC option from the GA Settings Variable and used it on the Page View TAG instead.

So why not do the same?

In our situation, this isn’t an inconvenience. In fact, we want info about the user or his login status to always be there for each hit. We want these custom dimensions associated with the hit, the session, or to the user. It is not a problem if they are passing through each Google Analytics tags. This is why we’re using the Google Analytics Settings variable for such iteration.
EEC is for a product, we don’t need this purchase details to be reported for other hits expect to report that there’s been a purchase only, that’s it.

What if there are no values for our URL queries (like the affiliate etc)?
That’s not a problem, GTM will just put a value of “undefined”.
For example, in the image shown earlier of the console using the Debugger extension, instead of “1234”, “social” or “logged-in” you’ll have undefined.


Start building a plan, and take some your time to do it which can help you think through and implement what you need faster. Think about where you need to customize? what information would require its own custom report in Google Analytics or even in Data Studio?
Also, think about where is the information you’re looking for? Because this will inform your next steps. Is this information passed through an URL like the examples of this post? or is it available in your data layer?

💡 Pro Tip:
It’s preferable if you can get it into the data layer and then read the data from there. It’s the best solution but its unfortunately not always possible.

Don’t forget that in GA, you must set up first an index number. Then you can use Google Tag Manager to refer to this index number to provide its value. GTM will use it as a reference to connect it to your GTM settings.
Again, do not forget that the data layer is the best place to put your values. You can use the data layer variable for values when you’re custom dimensions and metrics. This may require the help of your developer so do remember to include them in the conversation to help you.

Additional Important Resources:

Check Simo Ahava’s Articles

Note: the one about product scope is the one that speaks of t-shirt size/color