Tuesday, April 16, 2024
No menu items!
HomeData Analytics and VisualizationA Guide to Custom Dimensions in Google Analytics 4

A Guide to Custom Dimensions in Google Analytics 4

Updated: August 11th, 2021

The thing with Google Analytics (or any other similar tool) is that it won’t help you much if you use it just “out of the box”. I’m talking about the classic “just add one line of JavaScript to your site and start tracking”. If you want to benefit from a platform, you have to customize your data collection.

Every business is unique and you might want to track different things in order to understand how different parts are performing.

And one of the ways how you can customize it is custom dimensions. Instead of just having some generic data, you can go really deep with your setup. Even though Google Analytics 4 offers better automatic tracking capabilities (compared to Universal Analytics), that’s not enough.

In this blog post, I’ll show you how to configure Custom Dimensions in Google Analytics 4 (with Google Tag Manager).


Table of contents

+ Show table of contents +

How to read this guide?
PART I: Let’s start with some theory about dimensions
1.1. What is a dimension?
1.2. GA4 Custom Dimensions vs Universal Analytics Custom Dimensions
1.2.1. Scope in Universal Analytics
1.2.2. How scope has changed in Google Analytics 4

PART II: The setup of custom dimensions + reports
2.1. The process of creating Custom Dimensions in GA4
2.2. How to Configure a Custom Dimension in GA4
2.3. Register custom dimensions
2.4. Where can I find custom dimensions in GA4 reports?
2.5. User Properties

Final words



If you prefer video content, here’s a tutorial on my Youtube channel (subscribe to stay up-to-date with GA4). But to get the most out of it, I recommend doing both: reading this article and watching the video.

IMPORTANT #1: I did a mistake in the video at 17:12. Please read the description of the video for more information.

IMPORTANT #2: some parts of the Google Analytics 4 interface have changed (compared to the video below). Custom Dimensions are now managed in Configure > Custom Definitions.

Note: recommended event in the video above, I accidentally used a custom event name for the form submission. There is a called “generate_lead” that you can use.


How to read this guide?

I have split this blog post into two major parts:

An introduction to custom dimensions, some basics about Universal Analytics scope, and how that changed in Google Analytics 4
An example of how to configure custom dimension in Google Analytics 4 with Google Tag Manager

If you want to skip just to the practical part, feel free to do so. But if you find something confusing, then read the first part as well.


PART I: Let’s start with some theory about dimensions

In this part, I’ll briefly explain what are dimensions and their scope in previous and current versions of Google Analytics


1.1. What is a dimension?

Let’s start with the basics (because some readers of this blog post might be new to the game). What is a dimension?

Simply put, it’s a parameter/attribute or characteristic of data. It might be an attribute of a product, event, user, website, etc. It helps us better describe and understand what is happening, where is it happening, when is it happening, etc.

If this does not sound clear, here are some examples:

A transaction occurs on a website. Its dimensions can be (but not limited to):
Transaction ID
Coupon code
Latest traffic source, etc.

A user logs in to a website and we send the event login to Google Analytics. That event’s custom dimensions might be:
Login method
User ID, etc.

A product is purchased. Its dimensions can be:
Product name
Product category
Product variant
Product size, etc.

A logged-in user opens his/her account. Dimensions of a user can be:
User ID
Registration country
Pricing plan, etc.

To sum up, dimension is a parameter that describes something. What about custom dimensions?

Custom dimension in basically any attribute that you additionally configure in your analytics tool because the default functionality does not cover that. And that’s where we move to Google Analytics.


1.2. GA4 Custom Dimensions vs Universal Analytics Custom Dimensions

Even though there is a bunch of dimensions in Google Analytics (especially in Universal Analytics), they cannot cover all the possible situations, thus custom dimensions are needed. Things like Page URL are universal and apply to many cases but what if your business is selling online courses (like I do)?

In Google Analytics, you will not find any dimensions related specifically to online courses. Why? Because probably 99.9%+ of businesses using GA have nothing to do with courses. And that’s why anything related specifically to online courses should be configured manually.

Enter Custom Dimensions.


1.2.1. Scope in Universal Analytics

In this blog post, I will not dive deeper into custom dimensions in Universal Analytics. If you want to do so, read this guide.

If you’re at least a bit familiar with Custom Dimensions in Universal Analytics, you probably have heard of something called “scope”. The scope defines to which events will the dimension apply.

In Universal Analytics, there are four scopes:


User scoped custom dimensions are applied to all the hits of a user (hit is an event, pageview, etc.). For example, if you send User ID as a custom dimension, it will be applied to all the hits of that particular session AND to all the future hits sent by that user (as long as the GA cookie stays the same).

Session scoped dimensions are applied to all hits of a particular session. For example, you could send the session ID custom dimension, and even if you send it with the last event of the session, all the previous events (of the same session) will get the value. This is done in the backend of Google Analytics.

Hit scoped dimension applies only to that particular event/hit (with which the dimension was sent). For example, you can send an event “trial started” to Universal Analytics, and together with it, you can include an additional parameter “pricing plan”. That dimension will be applied only to the “trial started” event.

Product scoped custom dimension applies only to a particular product (that is tracked with Enhanced Ecommerce functionality). Even if you send multiple products with the same transaction, each product might have different values in their product-scoped custom dimensions, e.g. “product size”, “product color”, etc.

Why am I telling you this? Because some things have changed in Google Analytics 4.


1.2.2. How scope has changed in Google Analytics 4

In Google Analytics 4, the session scope is no longer available (at least in custom dimensions). If you want to apply a dimension to all the events of a particular session, you must send that dimension with every event (that can be done on the level of the code (gtag) or in GTM). And the implementation depends on where do you have that data in the first place. It can be in a cookie, in the data layer, or somewhere else.

From now on, custom dimensions are either hit-scoped or user-scoped (previously known as User Properties).

User-scoped custom dimensions in GA4 work similarly to the user-scoped dimensions in Universal Analytics but with some differences:

In Universal Analytics, a user-scoped custom dimension (set in the middle of the user session) was applied to EVERY event of the same session (even if some event occurred before the dimension was set). In GA4, User Property is set to all the events but from that particular moment going forwards. Past events of the same “session” will are not modified (because GA4 tries to ditch the concept of a “session” (to some extent)).
The process of how user-scoped custom dimensions in Ga4 are configured has changed too (I will explain it later in this blog post)
You can have up to 25 user-scoped custom dimensions in a single GA4 property (which is a much higher number compared to the “20-custom-dimensions-limit” in free Universal Analytics that applies to dimensions of all scopes).

Speaking of product-scoped custom dimensions. Even though you can send custom product data to GA4, at the moment, there is no way to properly see it in reports. Hopefully, this will be changed in the near future. Or am I missing something? (let me know).


PART II: The setup of custom dimensions + reports

And now let’s move to the 2nd part of this blog post where I will show you how to configure custom dimensions and where to find them in Google Analytics 4 reports.


2.1. The process of creating Custom Dimensions in Google Analytics 4

First, let me start with a general overview of the process, and then we’ll take a look at an example.

Google Analytics 4 is pretty flexible when it comes to sending custom data to GA. If you use it to mainly stream data to BigQuery and then do the analysis there, you can send any custom parameters you want and they will be visible in BigQuery.

You can just send the event name, say, “joined_waiting_list” and then include the parameter “course_name”. And that’s it. However, if you want to use that parameter in the GA4 interface (and you will most likely, do), then you have to register that custom dimension in the GA4 interface. In that case, you will need to:

Register a parameter as a custom definition
Start sending custom parameters with the events you want

The order DOES NOT matter here. But you should do that pretty much at the same time. If you start sending the parameter to Google Analytics 4 and only register it as a custom dimension, say, 1 week later, your reports will be missing that 1 week of data (because the registration of a custom dimension is not retroactive). However, raw data (e.g. streamed to BigQuery) will properly contain that parameter.

So, you might be wondering “what is the registration of a custom dimension?”. Let’s take a look at the example.


2.2. How to Configure a Custom Dimension in Google Analytics 4

If you are new to event tracking in Google Analytics 4, you might want to also take a look at this guide (+ video).

In this example, I’ll be tracking menu link clicks. Every time a visitor clicks on a menu item, I will send an event and two additional parameters (that I will later register as custom dimensions), menu_item_url, and menu_item_name.

Note: menu link click tracking trigger conditions differ on most websites (because of different click classes, IDs, etc.). Try to do your best to apply this example.

On a demo website, I have several menu links that I want to track.

First, I need to create a trigger with correct conditions that distinguish any click from a menu link click. Enable Google Tag Manager’s Preview mode and try clicking any of the menu links on a website. Once you do the first link click, you should see the Link Click event in the Preview mode’s left sidebar.

If you don’t see it, you should:

have at least one Just Links GTM trigger activated on a page
or have “File download” or “Outbound links” tracking enabled in your Enhanced Measurement Settings within GA4

Let’s say, that you don’t use Enhanced Measurement in GA4. Go to Google Tag Manager > Triggers > New > Just Links. Keep the trigger set on “All link clicks” and save the trigger.

By creating this trigger, we will enable the link-tracking functionality in Google Tag Manager.

Then go to Variables > Configure (in the “Built-in Variables” section) and enable all Click-related variables.

Refresh the preview mode (by clicking the Preview button once again).

Then go to your website and click any of the menu links. Actually, click at least two of them. Return to the preview mode and you should start seeing Link Click events in the preview mode. Click the first Link Click event and go to the Variables tab of the preview mode.

Then click on the second Link Click event. I am currently looking for some variable that I could use to distinguish a menu link click. I don’t want to fire my GA4 event tag on any link click. I want to fire it precisely on a menu link click.

After taking a closer look, I see that both links contain the same Click Classes value, site-nav__link site-nav__link–main. By the way, nav means “navigation” in this context. Great! I will use this in my Just Links trigger.

Go back to the list of triggers in your GTM container and click the previously created trigger for All Link Clicks. We’ll edit it and add a condition: Click Classes contains site-nav__link–main

Save the trigger. Now, it’s time to create a Google Analytics 4 event tag. Go to Tags > New > Google Analytics: GA4 Event. Select your existing GA 4 Configuration tag and then enter the event name. Its value is up to you. Any of the following options are perfectly fine:

menu click

These are just some of the examples. Since we are working with a custom event, we can name it whatever we want (as long as we follow the limitations of name length, for example).

In my case, I used menu_click event name. But this time, sending just the event name alone is not very useful. You’d probably want to know which exact menu items are clicked more often. How about we also send the name of the menu item and the URL?

We could do that by sending additional event parameters. Even though you could use parameters that are already mentioned in the documentation of the Enhanced Measurement (like link_url and link_text), let’s create two custom parameters (because I just want to show you how to configure them).

I am going to pass two parameters, menu_item_url and menu_item_name. I made these parameter names up and you can do it too. That’s what the flexibility of the data model offers.

To send custom parameters, you must expand the Event Parameters section in the Google Analytics 4 event tag and then click Add Row.

Enter the name of the first parameter. In my case, that is menu_item_url. In the Value field, I will insert a variable that returns a clicked URL. Luckily, GTM already offers such a variable, it’s called Click URL. Click the Insert Variable button and then select the {{Click URL}} variable.

Let’s add another parameter, menu_item_name. For that purpose, GTM offers another built-in variable, {{Click Text}}. Insert it as well. Since visitors of your website can translate your page, {{Click Text}} value will also change, hence you will see a more diverse list of collected values in your GA4 reports.

If you want to send more parameters, you are free to do that. You can send up to 25 custom parameters with a single event. These two parameters will eventually become custom dimensions in Google Analytics 4.

Assign the previously created Just Links trigger to this tag. Save the tag. Refresh the GTM Preview mode and click a couple of your menu items. Go back to the Preview mode and click those Link Click events. Check if the GA4 event tags for Menu Link Clicks have fired.

Now, you will need to go to Google Analytics 4 and check the DebugView. You will learn more about that in this chapter of the blog post.

And now the time has come to register those parameters as custom dimensions.


2.3. Register custom dimensions

This applies to any event parameter that you send to Google Analytics 4. If you want to see/use them in things like Funnel exploration, Free Form, see their reporting cards in standard reports, etc., you must register custom parameters in the GA interface.

In Google Analytics 4, go to Configure > Custom Definitions. Since we sent 2 custom parameters with the menu link click, we must register them both here.

Click the Create Custom Dimensions button and then enter:

The name of the parameter. You can enter whatever you want. This is just how the dimension will be displayed in your reports. You can name it “menu_item_url”, “Menu item URL”, or anything else.
Scope. Since we want to apply this parameter only to one event (and not to all events of the same user), we need to select Event
Event parameter. This is where you have to enter its name precisely as you entered it in the GTM tag. If your parameter name is menu_item_url, you must enter it here exactly like that. Don’t worry if the autocomplete feature of that field does not show your parameter yet. Just enter it and save the dimension

Then register a second parameter (in my case, that was menu_item_name) and save it. By the way, I sometimes use the words “custom parameter” and “custom dimension” interchangeably. In general, custom metrics and custom dimensions are both grouped as custom parameters.

And now we wait. Within the next 24 hours, the custom parameters will start appearing in your Google Analytics 4 reports.


2.4. Where can I find custom dimensions in Google Analytics 4 reports?

This blog post focuses mainly on the setup of custom dimensions in Google Analytics 4. I will not dive deep into how to find insights, raise questions, answer questions, etc. However, I can show you several places where you can find the dimensions you have just sent to Google Analytics 4.

Here are some of the reports:

Configure > Events (this will show just the list of events with counts. Nothing fancy.
Reports > Engagement > Events
Explore (a.k.a. Exploration reports)

But that is not all. Since GA4 is an event-based analytics platform, every report is affected by events that you send (in one way or another). The aforementioned reports are just the most notable examples.


2.4.1. “Reports → Engagement → Events” report

This is an overview of all events that were sent to your property + a couple of charts. Below them, you will see a list of events and if you click on any of them, you will take a closer look at that event’s data.


2.4.2. Explore (a.k.a. Exploration reports, ex Analysis Hub)

This is the place where you will be able to drill down into your data. In the Explorations, you will be able to use reports such as Free Form, Funnel Exploration, Path Exploration, etc.

Here is an example of a Free Form report. Keep in mind that you will need to wait for up to 24 hours for the data to come into your reports. So if you don’t see the data now, be patient.

Let’s say that I want to see how different device categories are interacting with the menu bar of my site. Remember, I set up the menu_click event?

So, let’s go to Explore and click on the Free Form block.

Then in the Variables column, I need to include the menu_item_url custom dimension because I want to see how many clicks did get each menu URL. Click the Plus icon and then find the menu_item_url dimension. Select it and it will be included in the list of possible dimensions in the report.

If you CANNOT see the menu_item_url (or whatever custom parameter are you looking for), you must register that custom parameter in Configure > Events > Manage Custom Definitions. And then wait for 24 hours until the data appears in the reports. If the reports don’t work properly, wait for even longer.

Then let’s edit the Tab settings. Remove the existing dimensions in the ROWS and include the custom definition that you want to include. In my case, that’s menu_item_url.

In the COLUMNS section, I used the Device category dimension. In the VALUES section, select the metric that you wish to see. I used the Event Count.

Then you will need to filter only to those events that actually contained the menu_item_url dimension. In my case, that is just a menu_click event. That’s why at the bottom of the Tab Settings section, you should enter a filter: Event name exactly matches  menu_click.

That’s it, your report will now display how different device categories are clicking menu items; which ones are the most popular and how many times were they clicked.

Also, don’t forget to change the date range if you need it. You can do that in the top-left corner of the Exploration interface.

You can also use event data in things like funnel reports, but let’s keep it for another tutorial (hopefully) in the future.


2.5. User-scoped custom dimensions

As promised, it’s time to talk about user-scoped custom dimensions. If you have ever worked with user-scoped custom dimensions in GA3, the concept here is pretty similar. The main difference is that in Universal Analytics (GA3), a user-scoped custom dimension (set in the middle of the user session) was applied to EVERY event of the same session (even if some event occurred before the dimension was set).

In GA4, user-scoped custom dimensions are set to all the events from that particular moment onwards. Past events of the same session will are not modified).

Also, one more difference is that if you want to send the user-scoped custom dimensions with GTM, you have to use a different section in the GA4 tag (see the screenshot below). Use User Properties, not Fields to Set. 

I know, it was not the best decision on Google’s behalf to use “User properties” and “User-scoped custom dimensions” in the same context.

When you send the user properties to Google Analytics 4, you also have to register them as user-scoped custom dimensions in the GA4 interface.  To do that, you have to go to Configure > Custom Definitions > Custom Dimensions and click Create Custom Dimensions.

Then enter the following settings:

Make sure the scope is User.

As always, you will have to wait for up to 24 hours for the data to start appearing in reports.


Custom Dimensions in Google Analytics 4: Final Words

In Universal Analytics, Custom Dimensions were more like an intermediate feature and many marketers were not even using it (insert sad emoji here). With the rise of Google Analytics 4, custom dimensions have become the fundamental functionality that is needed even for very beginners. If you want to track an event and include any additional text parameter, you’re basically dealing with custom dimensions.

The process is pretty straightforward here. You have to send some custom data to GA4 and you have to register a parameter as a custom dimension (if you want to use/see that parameter in regular Google Analytics 4 reports).

But if you are using Google Analytics 4 just to stream data to BigQuery and do the analysis there, then there is no need to register dimensions. Even unregistered parameters will be available in BigQuery.

Got some questions about custom dimensions in Google Analytics? Feel free to post a comment below.


The post A Guide to Custom Dimensions in Google Analytics 4 appeared first on Analytics Mania.

Read MoreAnalytics Mania



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments