How to implement Google Analytics and Adwords conversion tracking using GTM

Let's start

In this post we will run through two common use case for google tag manager. Implementing google analytics page tracking and adwords conversion tracking using gtm.

Using Google Tag Manager to implement Google Analytics

Google Tag Manager is a new solution by google that allows you to create a single script tag to all the site pages and then deploy additional tracking code to the site directly from gtm’s web interface.

Setting up GTM

To begin with GTM you will need to visit Once you login, there will be an option to create a new tag manager account or use an existing one. For simplicity you should create a new account for each of your web properties.

  • Give the account and container a name
  • Select the timezone (ideally same as the GA account)
  • Add domain name(s)
  • Click create account

On the next page you will see a script tag. This is the code for the accounts GTM container and needs to be added on all pages of site after

Below the code you will see an option to create a GA tag. Clicking this will take you to a new page where you can setup GA tracking for the site.

This is how it would look

 Add a new tag

Add a new tag

  • Give the Tag a name
  • Enter the accounts UA code
  • Specify Track Type to Page View
  • Click Rule to Fire Tag in the dialog select all pages.
  • Hit Save






Your tag is done. Next thing is to deploy the tag.

Click Create Version button on the Overview screen to push this tag to the container.

Next you can click Publish to push changes live.

And Voila we have started using GTM for google analytics tracking.

Caution: Before you publish any GA code present on the site using the standard tag should be removed. Container script should be present on all pages.

Now the real deal

The actual power of gtm comes from its ability to allow us to add multiple tracking scripts and trigger them on specific pages based on predefined condition.

Rules tell gtm when a tag should be run.

Imagine setting up new goals and virtual pageviews by just setting up new tags or adding adwords remarketing / conversion tags to specific pages without a single code change that is now possible.

Before you dive in to details you should read an overview to google tag manager

So how would this work?

There are pre built templates available in gtm for the tags of different google services. Let’s run through a common scenario for triggering an adwords conversion tag:

From the overview page you can create new tags. Select New Tag

On the next page you will see a blank tag. Here you can choose from a variety of tag types. For Adwords conversion tracking we will select Adwords Conversion Tracking You will now see the template for an adwords conversion tag loaded. You will see 3 fields which need to be filled.

At this point go to the adwords account and generate a conversion tag. This is what it would look like

<!– Google Code for test Conversion Page –> <script type=”text/javascript”> /* <![CDATA[ */ var google_conversion_id = 142364; var google_conversion_language = “en”; var google_conversion_format = “2”; var google_conversion_color = “ffffff”; var google_conversion_label = “sP9wCKrgagQQQuMyi5wM”; var google_conversion_value = 1.5; /* ]]> */ </script>

From this we can extract the values in bold:

  • id: var google_conversion_id = 142364;
  • label: var google_conversion_label = sP9wCKrgagQQuMyi5wM;
  • value: var google_conversion_value = 1.5;

Add these to to tag template.

Now comes the time to specify the rule this is how you tell GTM when to trigger the tag. Click Add Rule to Trigger Tag

On the next dialog we want to select Create a new rule:

  • Give the rule a name
  • Select what conditions need to be met for the rule to trigger
  • Most common condition is to specify a url to trigger the tag. This will likely be url of thank you page.
  • We can also go a step further and make sure only user coming from a specific page is counted as converted.
  • To do this click the plus sign and add another condition
  • Select {{referrer}} contains then specify the page url a person most come from to be counted as converted.
  • Once done hit save to add the rule.
  • Now save the tag.

You will now be back at overview screen. Select Create Version to add changes to container.

Now click Publish to make this new version of container live on the site.

And we are done!

This just two simple example there is a lot more ability in GTM to more or less run every type of js even custom code.

When you are feeling more curious checkout my post on using custom javascript in tag manager to do advanced tracking

Let me know if you have any questions in the comments. Look forward to the feedback.

Don't miss out when new resources launch

Our customer analytics experts share wisdom only once a month

Share now
We are customer-analytics consultancy that transforms messy data into actionable insights that will help you grow your company and make better data-backed decisions.