How to Label Users in Google Analytics with Google Tag Manager

It’s common to label or tag your users in your CRM, but how can you do it in Google Analytics? In this tutorial, we’ll discover a simple technique to label our users directly in Google Analytics on our Website. And of course, we’ll do this with the help of Google Tag Manager

In this video, I’m going to show you how you can label a visitor within Google Analytics with the help of Google Tag Manager. All and more coming up.

Hey there measuregeeks, Julian here back with another video for you. Today we are live on the channel. This is a live recording. And we’re gonna give you a little bit of a tour of how to label a visitor within Google Analytics with the help of Google Tag Manager. If you want to be online and actually asked questions which I’m going to answer after this recording, then a new few seeing this actually after the fact and you should definitely subscribe to our channel and hit that bell notification icon. So you’ll be notified once we go live here on this channel again.

Why Label Users in Google Analytics?

Alright, today we want to talk about how we can label a visitor within Google Analytics. What does this actually mean? Well, if you have a CRM system like MailChimp, or Active Campaign, or HubSpot, you might be familiar that you be able to go into a contact record and actually assign a tag to a user. You can label this user or tag this user and say, Hey, he bought this product, or he has… he’s a newsletter subscriber, for example. That is valuable information that sticks to the the user profile of the user inside your CRM system. And then you can backtrack later on or filter by the tag, for example, all the users who have this tag.

We can actually do the same in Google Analytics. And this can be quite useful because we can also filter and segment our users within Google Analytics, and maybe one or the other user group or a user who was tagged in a certain way and is behaving in a different way. So you can look at for example, all your past customers You are ecommerce shop, or you’ll be able to look at everybody who has logged into your product. And if you are a SAS or a tool that requires a login, and you could look at all these users and segment them out for looking for prospects or looking for people who have logged in who are actual customers already. Or people who you actually want to filter out as well.

So, for example, internal users of your platform, users of the colleagues, for example, you could tag these people who come to your Google Analytics and filter those people out so they don’t pollute your analysis later on in Google Analytics. So labeling visitors can be quite useful within analytics. And today, I’m going to show you how to do it. So let’s dive into a little demo here. I’m gonna switch over to my screen right here. Let’s put this on to the top actually, and we’re here in our demo shop. Now in our demo shop, we have already installed. as you can see down below, Google Tag Manager and the normal Google Analytics pageview tag.

Example 1: Labelling Site Visitors Who Are Newsletter Subscribers

Now, I want to introduce a little bit of a case here, where what we want to install today. So let’s say we want to label all the visitors that come to our page, who are already newsletter subscribers. Because we, for example, don’t want to analyze our newsletter subscriptions based on the users who have already subscribed, but the people who haven’t subscribed yet and see how we can optimize the website. So we would need to attach an attribute, a property to the user and to use a record within Google Analytics. So how can we find users who already subscribe to our newsletter? Well, when we send out a new setup, for example, I sent this newsletter to myself here, we can put in links that point to our website. And once I click this link, hopefully your links are UTM tagged.

Using UTM Parameters

So when we go to this website, we have a UTM tagged link right here. And that tells Google Analytics which column, which road to put them in into our source medium reports. You might know about this, if you don’t know about this, you should definitely check out our video on UTM tagging. But we can actually use this information as well to tag our user as a new set of subscribers. So every time a user comes to the website to this link, then that’s something we should tag later on.

Let me just check over here and see, okay, let’s go on. I’m just checking the sound here. Let’s go on and this information is now available on this page. At least To the US and also to Google Analytics. So within Google Tag Manager, we can go ahead and take this user information app. And or take this as a trigger and fire a new attribute to Google Analytics and tell Google Analytics this is a user who is a newsletter subscriber. Now, how do you tell Google Analytics this?

Using Google Analytics Custom Dimensions

And this is where Custom Dimensions come in. Now, custom dimensions are attributes that you can attach to data. Every time you send over data to Google Analytics, like a page view or an event, you can add a given role to or a new column to the data set. And obviously, you know, when you send over page view, the page URL gets sent, or the screen size of the user gets sent, or where the user just came from, gets an and parameters get sent. We can actually attach customer information to it and tell Google analytics this is a newletter subscriber or not.

So first of all, we would need to configure in Google Analytics. Let’s go over to Google Analytics, our custom dimension. So where we can do this and this is customer information, go into the admin section here. And in your property settings so in the middle row here, you can go under the custom definitions, and here you have custom dimensions. And you can see I have already set up some custom dimensions for this account. But if you’re new to this, you can click here on new custom dimension, and enter a name for your custom dimension. You can call this whatever you want, for example, in our case would be is this user a subscriber? Now then you use the scope, the scope, that’s something you need to configure. And this is really about where you want to attach this information and how it gets processed.

Now, I don’t want to go into deep into scope. We actually have another video of what is scope in Google Analytics, you should definitely check it out. If you don’t know what scope is, but what this functionality will do is when we use the user scope here, it will attach it to the user in Google Analytics. So as long as the user has the same cookie, or the same client ID or the same user ID, this information will persist throughout his user record. And this is very important because we only can, we only need to fire our custom dimension once when the user comes, for example, to this landing page. And then this information will persist throughout his lifetime of being a user in Google Analytics. So we can create this I won’t do this right now because I actually have a custom dimensional already set up right here. And once you once you click create this dimension, you will get this little window here. And the information that you really just need is the number of the dimension in our case, it would be four.

So if we click cancel here, we see also the index is number four. This is a number you need to remember. So now inside of our demo shop here, well, actually this one, we want to fire a custom dimension every time somebody comes with the UTM source newsletter. So I would say let’s, we can do this in different ways. But since we are looking at the URL right here, let’s build a custom variable, first of all, that will detect what is in the UTM source, or maybe take UTM medium. Let’s take yeah, let’s take UTM source because maybe you’re sending out an email that is not a new setup.

Building a Custom Variable in GTM

So let’s go ahead and Google Tag Manager and just build a custom variable. So user defined variable and This will go into our URL scope. Or we’re looking at the URL type. And we’re going to look at UTM source. UTM source is a URL right here.

And then we’re looking at the query parameter, which is UTM Source. If you don’t know what query parameters are, this is also something we explain in a video. But I can pull out whatever is behind the equal sign of the UTM source right here. This is a query string, and the parameter of this query since UTM source and we want to pull out the newsletter. So I’m gonna put this here in here. And let’s save this internet is slow because I’m actually streaming at the same time. Refresh this, go back to our page. And let’s reload this page actually going to close this page.

Alright, well, this loads pretty slow. Okay. Now our previous debug mode is loading. And we should be able to see in our variables here that our UTM source is now newsletter so pulled out directly this what I wanted. Now I need to have some functionality in there to tell Google Analytics if this is the newsletter, then turn something to true. Why do I want to do this? Because I want to send in an attribute to Google Analytics and to this describe a column subscriber column of the value of true so I need to rename this somehow. And I can do this with a easily you can do this with a custom JavaScript variable.

Creating a Look up Table Variable

But another way to do this would simply be a lookup table. So I’m going to build a lookup table variable. That will look into my UTM source variable. And every time it finds news attender vagaba, I want to rewrite it into true.Alright, that should do it. Let’s refresh and try this out again.

And now we should see can all see this in slow mo here. That our lookup table variable that we have just built is now true because we have this newsletter industry. So let’s do a negative test, let’s say just whatever. If the user doesn’t have the source newsletter in there, this should just turn undefined, hopefully. So here we have lookup table undefined. Now undefined is very important because Google Analytics will actually ignore undefined. And therefore we can just put it in there.

Sending the Dimension Value to Google Analytics

And this is really it ready, we can now attach this to our Google Analytics, pageview tag. So in Google Analytics, we already have a pageview tag created I have done this beforehand. And here in the settings, you can override enable override settings. And that’s how you get these two menus down here. If you don’t want to do this, you could also put this into the Google Analytics settings terrible for simplicity sake, I will just unable to override settings And here under more settings, I will go with custom dimensions. And here I need to enter the index. So as you remember the indexes right here we have our index is number four. And therefore I will put in the number four. And then the dimension value will be the value that I want to push actually into discussing dimension.

So into this column that I have prepared. And I want to push in true if the user is actually a new set of subscriber, if it’s not a new set of subscriber, I want to just have undefined and there because Google Analytics will ignore this. All right, let’s go ahead and simply use our lookup table variable to fill in this dimension value. Let’s saved this and refresh. And now if a user comes from a newsletter link comes to the page, our Google Analytics page view tag should fire and the page view tag, we have our custom dimension defined, which will pull out from our lookup table variable, which in turn pulls out from our URL variable. And therefore it should say true as the variable festival. Yes, he it’s true. And then for the page view, it didn’t find this one. But it fired here, the page view we can see here that the field to set know, here Custom Dimensions index is true is now set to true.

Now we can also look this up in our developer tools. So if you have developer tools open, you can enable this extension GA debugger. And this will give you some information about what was sent over to Google and analytics. And right somewhere, here we go. So if you see this part right here, we have the dimension value four is true. And if you have a negative test right now, again, let’s go with just this XXX.


The user comes maybe from another newsletter or he comes from a completely different source, YouTube, Facebook and so on. He has not yet a new set of subscriber. Now I don’t want to set this field to false because obviously, this user might be a new set of subscriber already coming through a different source. Just want to set this to undefined. And right here, you can see that this is actually not part of the hit because Google Analytics ignore this information. It still tries to configure the tag. We see here, index for dimension value undefined, but in the actual Hit that gets sent, this information is not part of it. Now, it’s a bit tricky to see this information now in Google Analytics. Well, it’s tricky to see it. But it’s tricky to actually debug this information. Because in the real time reporting itself, we will not see custom dimension values that get sent over, we only see if there was a page view generated, which there was a second ago. But unfortunately, there’s no way to see like in the events, what data was sent over.

The only thing that we can hope for is to check back in an hour. So when that data is actually processed. And hopefully in the user explorer report, you’d be able to see the user. So for example, we need to go to our date right here. And you know how every user gets a client ID going to go into the developer tools and look up my client ID here. I have a client ID with 661. And in Google Analytics, we have one user with a session three sessions already 661. And then right here, you should see subscriber custom dimension is true. Unfortunately, this has not yet been processed. So it’s not in here quite yet. But we should see this later on as a subscriber true.

Use Cases for these User Labels

Now, how can you use that data in Google Analytics, then?

Building an Advanced Custom Segment

First of all, you could build a custom segment. So as you might be familiar with custom segments appear, can build a new advanced custom segment. Oh, here we go. We can just say a new segment and every user that has a way to go, just go with the condition filter, every user who includes the attribute, subscriber, and this is what we have named The custom dimensions so we can find it here. subscriber contains true or equals true.

Exactly matches true. So we have one user 50% of users who are most definitely website, we can say, subscribers. Now we have a segment where we have filtered down to everybody who is a subscriber. And this will actually persist. So if if the user goes to the next link and clicks on, I don’t know clicks on this link, the user property within Google Analytics will persist. So this user will stay tagged or will stay labeled as a subscriber.

Building Filters

This is also true when you want to, for example, filter out user so you could build a filter based on this and say the view setting or inside of the filter settings right here. You could filter by people who have this attribute, right, so you could build a filter and say only subscribers or without subscribers. And this will be a exclude field, we want to exclude users who have not yet in here.

Here customer mentioned subscriber filter pattern is true. So you will exclude everybody who is a subscribing you can use it in the exclude filters. And you can also use it I’m not going to configure this and you can use it in any kind of other report. So for example, if you go to our all pages report, this is just an example you would find this others of you always know you have a table down here. And now if you would like to only look at subscribers, so right now we’re looking at subscribers because we have a Custom segment on here, you can add this as a secondary dimension subscriber. Now, I will tell you if this is true or false.

For so far, for our case, it would be true. But if we have a subscriber that doesn’t have this attribute, this would be empty, it would be filtered out actually automatically. So in the end, you can add this to any kind of table that you would like to just be aware that there is something called scope in Google Analytics. So you can mix and match all the data together. So if you get weird results, like no results at all, it might be that you’re running into this problem of scope in your reports.

Building Custom Reports

You can also customize a build a custom report. So we can go to custom reports here and create a new custom report for all our subscribers. And we add a metric now this needs to be User scope. So we will go with users and add a dimension, which is our subscriber dimension. So we have added a custom dimension to tag the users on the website. So we have one user who is true. And we actually see if our older users who when I was testing earlier, are tagged. No, not yet. Alright, so this is how you can then see this data in Google Analytics. Don’t forget, if you want to take this live to all your users, you will need to submit this as a version and publish this so it goes live onto your website. So you be henceforth tracking all your users and labeling them when they come to your website.


So this is already it’s with a little demo on how to label users with the help of Google Tag Manager in Google Analytics. Now this might be useful if you, for example, want to filter out users who are coming to a login page and login to your website. Or you want to filter out everybody who is actually already a customer comes to the thank you page, or you want to filter out or filter for people that have done a certain action. With Google Tag Manager, you can be really flexible in doing this and I hope you’ll come up with some other use cases that might be useful to you. And yeah, I’d love to hear from you in the comments below, as always.

And if you haven’t yet, then definitely subscribe to our channel right over there because we bring you new videos just like this one. And if you want to be live, definitely, definitely subscribe because we go live and I’ll answer questions after this video. So if you want to be part of this next time, subscribe to the channel. And let me know what you thought of this video and comments down below. Now my name is Julian, see you next time, in the next video, see you in the next video.


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Newest Most Voted
Inline Feedbacks
View all comments
Gerben van Wijngaarden
Gerben van Wijngaarden
1 year ago

Hi Julian, what’s the advantage of labeling the newsletter subscribers? If I use UTM coding, I already can make a segment of the newsletter subscribers, or filter them out, sorting them by medium or source? Why use the labeling?

By the way, keep up the good video’s, especially like your guitars in the background everytime!

Blog Categories

Join 30,000+ marketers getting exclusive resources and our latest content!

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.