HomeBusinessHow to migrate from Analytics to Google Tag Manager

How to migrate from Analytics to Google Tag Manager

Last month, I used the calm of the holidays to deepen my skills on Google Tag Manager . I finally decided to migrate to this tool, abandoning the Google Analytics tracking code inserted directly into the HTML.

The convenience of Google Tag Manager (GTM) is that you can edit and add new scripts on the page without actually putting your hand to the site, the basic operations can be implemented by everyone without having to resort to a Google Tag Manager consultant . GTM allows you to manage all scripts from a single platform, simplifying operations even in typical maintenance.

Before migrating to GTM, I had entered various trackings on the site: Google Analytics with related events, the conversion codes of AdWords and Facebook ADS, Remarketing AdWords and Facebook. Migrating to GTM I therefore had to move these characteristics that are certainly not secondary, let’s see how I did it.

PS: I recommend that you run the first test on a Google Analytics test profile. This is to avoid that, in case of errors, the data of the main profile can be ruined.

The screen with all the tags created in Google Tag Manager


  1. Insert the Google Tag Manager script into the site
  2. Migrate Google Analytics
  3. Migrate Google Analytics events : downloads, clicks on internal links and outgoing links
  4. Migrate the Google AdWords and Facebook conversion tag
  5. Migrate the AdWords and Facebook remarketing tag
  6. Read events in Analytics

Not sure what GTM is? Watch this video!

We insert Google Tag Manager on the site

First we need to create an account in Google Tag Manager. Let’s access the GTM website, navigate to the “Accounts” tab and click on the “Create Account” link as shown in the figure.

GTM Account Creation

In the second step we enter the container settings.

GTM Container Settings

Now we accept the terms of service and we will be able to find the code to insert on the site. This code will be the only one we are going to add to the site.

We insert the Google Tag Manager script on all pages of the site, it is advisable to place it immediately after opening the body tag.

GTM mainly works with two elements: Tag and Trigger . The tag is a container while the Trigger is the rule that defines when to activate the container. This means that for (almost) everything we want to do with GTM we will have to create two elements and connect them together. We will see that it is much easier to do than to say …

Migrate Google Analytics

We create the Google Analytics tag by selecting it from those proposed.

We select the Universal Analytics tag.

We enter the account data, select “Page View” as Track Type and also activate the advanced options to increase the sample rate for the calculation of the page loading speed and also activate the advanced link attribution .

  • In the “Field to Set” section we insert the Field Name“siteSpeedSampleRate” and as Value “100”
  • We select “True” in Enable Enhanced Link Attribution

We activate the tag on all pages for the correct functioning of Google Analytics.

Migrate Google Analytics events

Event: File Download

With Google Tag Manager it is very easy to track the downloads of certain types of files, it is no longer necessary to tag individual links on the website by hand. To track the downloads it will be sufficient to create a trigger with the right filters and each file corresponding to the rules inserted will activate the event. Convenient isn’t it?

To learn how to track downloads with Google Universal Analytics and Classic Analytics , read thisguide .

Choose the “Click” event.

Configure the trigger by inserting “Just Links” as Target with the mark on Wait for tags. Complete the operation by setting “2000” as Max wait time and inserting the mark on Check validation.

Enable the trigger on all pages so that clicks are tracked throughout the site.

Activate the trigger on all files that reside on our domain and that have the extensions we want to track. In my example I have filtered the following file types: \. (Pdf | txt | xls | xlm | xlsm | xlsx |) $

We create the tag to track downloads. We choose “Analytics” as a product, “Universal Analytics” as the tag type and insert the UA code of our account. To configure the characteristics of the event to be tracked in Analytics we insert in Track type “Event”, Category we can call it “Download”, Action {{Page URL}} and Label {{Click URL}}.

To enable the Click URL variable you have to select it from “Enabled Built-In Variables” as shown in the figure.How to enable the Click URL variable in Google Tag Manager

The last two commands will make sure to trace for each download the page where the link was clicked (Action) and the URL of the downloaded file (Click URL).

Event: Click on Internal links

I think it is very important to monitor clicks on internal links on the site. From this type of analysis we can understand which pages of the website contain useful links appreciated by users, or understand which pages attract the attention of our audience the most, and much more.

Select the “Click” event and configure the trigger as shown in the figure.

Enable triggering on all pages with the Regex command. *

We activate the trigger on all pages within the domain, excluding the file extensions already filtered with the Download event.

We create the tag to track clicks on internal links. We set up Google Analytics and Universal Analytics as usual. We insert the UA, track type “Event”, then we assign the category, action and label of the event as shown in the previous cases. Remember to activate the option not to change the bounce rate.

Let’s activate the tag with the right trigger

Event: Click on outgoing link

Tracking external / outgoing links is useful to understand from which page users leave our site most often and which external resources are most clicked.

Let’s create a new trigger. We choose the “Click” event and configure the trigger as shown in the images.

We enable the trigger on all pages to monitor clicks on links on each page of our site.

We activate the trigger on all clicks that do not contain our domain. Contrary to what is set to track internal links, if we want to track external links we must exclude all URLs inside our site

We create the tag to track clicks on external links. We set “Google Analytics” as a product and “Universal Analytics” as a tag type.
We enter the data of our account and set the tag as we have already done for the internal links.

We activate the tag on the “Click” and select the trigger created previously.

Migrate the Google Ads and Facebook conversion tag

With Google Tag Manager we can manage the conversion tags provided by Google AdWords and Facebook without having to put our hand to the site.

Google Ads

Let’s create the “Page View” Trigger and activate it only on our “thank you page”

We will call this trigger “Thank you for contacting us”.

We create the tag that contains our Google AdWords conversion tracking. We enter at least our “Conversion ID” and “Conversion Label”.

We activate the tag with the right trigger: Thanks for contacting us.


We will use the same trigger generated for AdWords: “Thank you for contacting us”.

We create the Custom HTML tag and insert our Facebook conversion tracking code . We insert the HTML code provided by Facebook into the Custom Tag. We activate the tag with the trigger “Thank you for contacting us”.

Migrate the Google Ads and Facebook Ads remarketing tag

To activate the remarketing tracking of AdWords and Facebook with Google Tag manager you do not need to create any trigger, just activate two tags on the pages that we want to include in the remarketing list – in this case all the pages of the site. We enter our “Conversion ID” and “Conversion Label”.

Google Ads


We create a Custom HTML tag, insert the remarketing HTML code provided by Facebook and activate the tag on the desired pages – in this case all pages of the site.

Read events in Analytics

The events we have created can be found in Google Analytics under Behavior> Main Events.

Google Tag Manager has saved me a lot of time managing the site and I don’t think I’ll go back. Having a centralized platform to manage all tracking is objectively useful.

did this article help you? leave a comment and share it with your colleagues



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments