Google Analytics Tracking Migration to Google Tag Manager (+ 3rd Party Tools)

This is a guide to migrating your existing third party tracking tools to Google Tag Manager. We will make use of the tag plan we have created on our previous lesson to guide us in every step and maintain data quality towards a successful tag deployment.

Test your knowledge

Setting Up PageView Tracking with Google Analytics

In this lesson, we’re going to learn how we can migrate over our existing tracking over to Google Tag Manager and henceforth deploy everything through GTM. All and more.

Hello there and welcome back to another video of teaching you the data-driven way of digital marketing. My name is Julian. And in our fourth lesson of our GTM for beginner series, we are actually going to get into implementing our tags with GTM. So we’re going to use the tag plan that we have prepared last lesson and going to put this into action, actually go through the whole migration process of taking our tags that are installed currently and putting them into GTM and making sure that everything works correctly. Now, we got lots to cover but if you want to test your knowledge after this video then head over to and I have a little bit of a quiz prepared for you there where you can test and see if you understood everything. For now ,we’ve got lots to cover. So let’s dive in.

Back in our Google Tag Manager account, we have a clear new installation of Google Tag Manager installed on our website. We did this in the second lesson. And we have already set up a tag plan. So we have all the data available that we would like to now implement. Now, we have found out that we have Google Analytics installed. We also click through the website in order to see where it’s installed. And that is installed probably on all of our pages. So we have Google Tag Manager, we have Google Analytics here, Ads remarketing and the global side tag. We have written everything down and now we are ready to implement.

Create a New GTM Tag

So let’s go over to Google Tag Manager and click on tags here or new tag right here. And this will open up our tag screen. Now, all tags, triggers and variables in Google Tag Manager receive a name from us that we can freely choose. This is part of the management aspect of Google Tag Manager. Imagine you have multiple tags, multiple tools running on your website, you want to be able to identify them later. And that’s where a naming convention comes in. So how do you name a tag correctly? It depends on your preferences. I normally utilize a naming convention. It first of all, let’s me know what tool I’m dealing with. In our case it would be Google Analytics.

The purpose of said tag in this case, we are just doing simple page you tracking. And the scope of where I’m installing this so is this just for one user, for all the users, for one specific circumstance. In my case it would be on all pages so this is the scope I will use. Now, if I have multiple Google Analytics tags, I would be quickly able to figure out which tag I would need to change in order to change the general page view tracking. So with this name out of the way, you can also put this into a folder. I won’t go into this right now. But there is the ability to sort all your assets into folders within Google Tag Manager. And then we get to the tag configuration. For the tag configuration, you can just click on this big field here. And we’ll open up the tag type option. This is where you can see different tools that you can install via Google Tag Manager. Now, once you scroll down here, you might not find what you’re looking for. And this is totally fine because we later on have the ability to also utilize the custom HTML tag, which I’m going to show you in a second. But for Google Analytics, we have this option right here.

Selecting Google Analytics Universal Analytics Tag

And I would always use this option if it’s available as it will give you a template or little bit of a form. So if I click on here, you see that it gives me all these different configurations that I might would have had set up inside of the code. Now, I don’t need to know coding for this, I can just fill out this form. So it makes it easier if you choose a tag type if it’s available. And then it takes me already through the steps. I can here choose the track type. So what kind of interaction do I want to send over to Google Analytics? We have the ability to send events, transaction, social timing, decorate links, and so on. For now, we want to send a page view over and then we can choose a Google Analytics settings variable right here.

Creating a Google Analytics Settings Variable

Now, there is no variable set up right here. For now. I will ignore this point and just use the enable override settings. Now, this option is really where Google Analytics would like to know your configurations for this tag. And since we might be reusing this information over and over and certain other tags, which will do in later lessons, we can set up

a variable, a placeholder so we can reuse it again. So let’s do this right now. Let’s choose a new variable here and build a Google Analytics settings variable. Again, you can give a name to the settings variable. In my case, it would be my tracking ID that I would like to save in the settings variable. So I’m going to go over to my Google Analytics account here under tracking information, I have my tracking code. And you might know we can do this much faster by going just into our tracking tag plan and copying this from our notes. Let’s go over here. I’m going to put this in as a name so I know where it’s actually been sent. And then I’m going to utilize this as well in my tracking ID field right here. Once I have to set up I can save it and this will now be used inside of this Google Analytics settings variable field and we will be able to utilize this again and again in other tag settings as well. Now, there are tons of more settings that we can do to this tag.

But let’s keep it simple. This will actually deploy already, your page view tag with the help of Google Tag Manager. So we don’t have to care about any of the other settings. Let’s go into the trigger which we need to choose. Now, triggers are simple rules that determine when should we deploy this tag. We can set up triggers to deploy only on one given page, for example, our conversion page. But in our case, obviously, we want to deploy it on all pages because we have looked this up. And so we want to migrate our Google Analytics page view tracking. And for Google Analytics page view tracking it’s actually important that you deploy it on all pages, as Google Analytics will take that data and put it all together into sessions and users, so it needs to be deployed on all pages. We’re going to click on this triggering option and this will give us our menu of all the triggers that we have already saved. Now, I don’t have any trigger save just yet. We will do this in a later lesson. For now. We’ll just go with the all pages trigger right here.

This is something that is already pre-configured for us and it’s wildly used. So it’s an option that is available to us. Now, what does that mean? The all pages trigger actually determines where is Google Tag Manager installed, where’s our snippet and sold and every time our snippet is executed, or on a page, it will also deploy our pageview tag. If you don’t have the GTM snippet installed on a given page, no Google Tag Manager will be deployed at that time. So now we have configured our tag. We can save this obviously, and it will be put into our tags right here. So we have a nice overview of what tags we have installed in our Google Tag Manager account. But as we have discovered, this is not yet live on our website.


To determine if it’s firing correctly, we can go into the preview mode right here.

And this will put our browser and only our browser into a special state. We will be able to go to our website, reload this website. And we get a little GTM debug console down here. And this gives us more information about what is happening on our page in terms of tracking and Google Tag Manager. So we see here we on a summary tab, and we can see our Google Analytics Universal Analytics fired one time. If we click on this tag, we can actually see all the different configurations that were done to it. And also the firing trigger.

Now, firing triggers are always evaluated or looked upon if they turn true or false on a event. And these are the events that you see right here. So on the page view event and again, click on the tag in here we see that our trigger turn true and it’s firing on the first possible moment. This is like a waterfall diagram. First, the page view happens, then this message happens, then the DOM ready and then the window loaded. So our tag fired on this event called GTM JS which is the pageview event with these settings.

Now, we shouldn’t just take Google Tag Manager’s word for saying that our tag deployed correct.

Using Tag Assistant

There are certain steps that you can take in order to ensure and check whether something has fired. First of all, we have our tag assistant. And our tag assistant shows us right here. Google Analytics is deployed, it shows it yellow. So we’re going to go in, and it gives us an error saying the same web property ID is track twice. So we are sending two page views over. This is expected behavior because as you might know, we already have a Google Analytics tag installed on our page. And this is hard coded. So we have down here, in the last lesson we looked at this, a Tag Manager code installed. Now on the live page, we would actually need to remove that later on. But let’s go through our testing and debugging even further.

The ultimate test is to actually look if your data is received by your tool. In this case, it would be Google Analytics. So let’s go over to Google Analytics. There’s an easy way to do this, and this is the real-time reporting. In the real-time reporting under the overview, we can see the different pageviews that are happening right now on our page from real users. And we would like to know if our pageview counted as well.

Using Google Analytics

Now, we could go in and just reload this page and generate a new pageview then go over to our analytics page and see whether we see any difference here. And there was a pageview with two page was actually at the same time tract, which hints at that this is our pageview tag as we are deploying two pageviews. Just a little trick that you could also use utilize is to attach something called UTM parameters to your URL. So for example, with a question mark and GTM source equals test press enter. The UTM source will be recognized by Google Analytics and we can go over in analytics to our Traffic Sources here. And now we should see a test pageview. No, we don’t see one.

Maybe because we didn’t enter a correct you UTM source actually UTM parameters always need to have multiple parameters so the UTM source needs to be filled out, the UTM medium and the UTM campaign. Let’s test this. Reload. Wait a second and here we go we have a medium test and a source test. So this was definitely us. If we click on it, this would actually put a filter up here on our page and when we go to content here we can see where the user that is filter down to test actually is at the moment. In our case would be happy ninja. Now let’s follow along. Let’s go over two albums here and see if this updates correctly. Yes, we see an update that is working. So we have the pageview tracking code correctly installed.

This is important to notice in our real-time reporting and make sure our data is tracked correctly. Just for data quality sake, we want to get complete data and not broken data right? Okay. So with that in mind, we have installed Google Analytics with Google Tag Manager. We have tested if everything works with preview debug mode, with our extensions, and then also ultimately with the tool that receives the data, everything seems to work fine. Now, we can go to the last step and publish this to all our users. For that, we would go over to the submit button and enter a message so we would know what we have done in this version of what the change would be.

If you have done more changes, you could also leave that in the version description down here and then we can publish and create a version which will then set our Google Tag Manager code live to the website which would mean that now our Google Tag Manager code deploys our Google Analytics live on our website. Now, we are still in the preview and debug mode. But if we would leave this, we load our page. We don’t see the debug console down here anymore. But as we can see in our tag assistant, our Google Analytics code gets deployed. It still the deploys two times because we still have the hard coded version on our page. So in this instance, we would need to get rid of the hard-coded version.

Removing Hard-Coded Version of Google Analytics

In our case, I’m running here on a WordPress blog, going to go into my WordPress settings. This might differ from your platform that you are using, I have it in the theme. So I’m going to edit my theme, my header php. And get rid of the implementation of my Google Analytics tag. This is this line of code that is implemented in the global side tag here. And I’m going to update this file. And now we can go back to our page, look at our tag assistant. And this time, it’s only firing once.

on the one pageview request and therefore, we are not doubling our pageview every time we send over a hit to Google Analytics. So now we have gone through the implementation process, tested in debug, deployed and also correctly migrated our code from the page source here into Google Tag Manager. So it’s only deploying once and not twice. That’s something you need to make sure if you have any hard-coded pixels on your page. Now, you might be saying stop, stop. We have some other codes here that we want to implement.

Installing Google Ads Remarketing Tracking

Let’s do this a little bit faster this time and port them over. So first of all, we have Google Ads here with this remarketing code. So I’m going to go over to the tags and build a new tag for AdWords or Google ads and this will be a remarketing tag on all pages. We have a tag template available here as well Google remarketing. We need our conversion ID which we have saved right here.And let’s put this in here. We don’t need to change any other settings.

Installing Facebook Remarketing Tracking

As a trigger rule, we choose all pages again.And then we get to a new tag which is Facebook ads, which also collects page views on all pages.

Now, this time we don’t find a tag template here. And therefore we can utilize the custom HTML tag which lets us input any kind of HTML code that we would like to deploy. Now, we have our facebook Pixel right here but in our page source we actually can see

right here what code we would need to port over. You can also again, look this up in your Facebook Ads Manager. We did this in our third lesson. So I’m not going to repeat this right here. But this is the code that I would need to implement. Be aware that you need to have script tags around your JavaScript right here in order for it to work. This is what we want to deploy again on all pages. Let’s save this. Do a quick test in our preview and debug mode. We have our Facebook Ads firing, our Google Ads firing on all pages. Let’s go over to another page to test this again.

Yes, this works as planned. In our tag assistant, we have hopefully our remarketing tags deployed and in our Facebook Pixel helper we have our pageview that still firing. Now again, I would recommend to go to the tools and see if you can view if there’s data actually received by the tools itself. I’m going to skip this step and go ahead and publish a version. Let’s publish this. And it’s live on our website.

Remove Other Hard-Coded Tags

And we can go ahead again and remove any kind of hard-coded tags. In my case, again, inside of our demo shop which is running on WordPress, I would need to remove them from the HTML which I have implemented in the header php of my theme. So right here we have our facebook pixel and we have our global site tag. This time we can delete both of those right so two and update the file and when we go back, we still have our Google Analytics, our remarketing and now Google Tag Manager deployed. And we still have our facebook pixel deployed as well. And that’s because we have now deployed them through Google Tag Manager. Let’s leave our preview and debug mode here and everything is still firing.

Now, when we look into the page source, you should not be able to find our codes anymore as we have removed them. So there are no more quotes here. But still, the data is gathered by our systems as we have deployed them now through Google Tag Manager. So we have successfully migrated our existing codes from our tag plan into Google Tag Manager and deploy them to all our users.


All right, so there you have it. This is how you can migrate your existing tracking over to Google Tag Manager and then deploy it. We went through the whole tag migration process and if you want to test if you understood everything, then head over to where we have a little bit of a quiz prepared for you. And if you want to follow along with the next lesson where we’re going to install our conversion tracking, then maybe this video is already available, head over to this video over there. Or if it’s not, then definitely subscribe to our channel right over there. Because we bring you new videos just like this one every week. Now, my name is Julian, til next time.


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Inline Feedbacks
View all comments

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.