An introduction to Google Tag Manager and collecting data

If you run Google Analytics or any kind of online advertising that requires multiple tracking tags to be added to your site (such as Google Ads or Facebook ads), then Google Tag Manager could be a useful way of implementing your tracking.

Guide

13 min read

1. Overview

Google Tag Manager (GTM) is a free tool that allows you to add tracking scripts and ‘tags’ to your website yourself, without always needing a professional developer every time you want to add a new piece of tracking. If you run Google Analytics or any kind of online advertising that requires multiple tracking tags to be added to your site (such as Google Ads or Facebook ads), then Google Tag Manager could be a useful way of implementing your tracking.

2. What are tracking ‘tags’?

When you want to gather information about how visitors interact with your website, you need to add tracking ‘tags’ to your site. These ‘tags’ are snippets of JavaScript code that extract and record information about your visitors, and send this information to their respective platforms such as Google Analytics or Google Ads.

Traditionally, each of these snippets of code needed to be created and manually added to the backend of your website (most likely by a developer). This manual ‘tagging’ could be time consuming for the developer, and could therefore incur costs and delays for website owners.

3. What is Google Tag Manager?

With Google Tag Manager, website owners and marketers can more easily create, add and update tracking tags themselves, without the need for each one to be ‘hard-coded’ into your website.

It is a free online tool which allows you to create tracking tags and add them directly to your website from its online interface. It is most commonly used in tandem with tools like Google Analytics, Google Ads and Facebook Ads to add their tracking scripts to your site. However, it can also be used to add tracking scripts and tags from a range of other platforms, including Search Console verification, heatmap trackers such as Hotjar, and many more.

GTM is not the same as Google Analytics (which is a reporting tool measuring how people interact with your site) or Google Ads (which is an advertising platform that allows you to run PPC ads). GTM is a tag management tool that allows you to add these platforms’ tracking code to your site, to enable you to use the Google Analytics or Google Ads reporting features.

Essentially, GTM enables you to add tags by adding an empty tracking ‘container’ to the back-end of your website, which can then be filled with the tags and pixels of your choice. Think of it as an access hatch directly to the backend of your site!

In the interface, you can also create custom tracking tags yourself - such as Google Analytics event tags - to track specific functionality within your website (which would traditionally have had to be created by a developer). GTM does this by creating the tracking code needed for these tags based on parameters that you input.

4. What are the benefits of GTM for small businesses?

Google Tag Manager comes into its own when websites require the ongoing creation and implementation of a number of different tracking tags. It provides a central hub for all of your tracking and allows you to build, alter and implement your tracking tags in a single online interface.

It is of most benefit to:

  • Digital-led businesses with websites critical to sales. For example, businesses which sell their products or services online, businesses where the site is their service or product (e.g. online training) or those where their website is central to new customer acquisition.
  • Businesses running many different online advertising campaigns that require the implementation of additional tracking tags, to help them optimise campaigns over the long-term.

However, GTM may not be necessary for all businesses, for example, if you have a small site with minimal functionality that does not require a large amount of custom tracking tags, or you do not do much marketing.

5. When you need developer support

Although you can create and implement tags yourself with a relatively small amount of technical knowledge, you will probably still require expert help from a developer with some elements, particularly if you cannot code yourself.

  • Adding container script. Initially you will need support in adding the GTM container script to your site’s back-end, unless you know how to code this in yourself or your web-builder tool offers built-in or simple integration.
  • Complex tracking. You may also require help from a developer if you need to create any complex tracking tags, or if the functionality you want to track requires additional HTML elements to be added to your site to be able to be tracked.
  • Custom script. We recommend seeking expert help from a developer before implementing any custom HTML or custom JavaScript to your site, as incorrect code could break your site’s functionality. For example, you may find some ready-made scripts online that claim to help you with a complex tracking implementation, and require custom HTML to be added to your site. These should be checked by a developer before they are implemented.
  • Lack of resource. Alternatively, you may feel that the time taken to learn this tool could be better spent elsewhere in your business and you may choose to outsource the set-up of your GTM account and tags to an agency or freelancer who is familiar with the tool. This would obviously require additional budget.

6. What you can do yourself

Although GTM is a relatively technical tool, once the container script has been added to your site, you may be able to plan, add and test straightforward tracking tags to your site yourself, from within the GTM interface.

To do this successfully, you will need to invest some time upfront to research the tool and become familiar with how GTM works and the basics of tracking code and JavaScript.

There is a good amount of information available online and in the Google Tag Manager help center.

Below we provide an overview of some basic GTM terms and an outline of the key steps to take to add your first tracking tag.

7. Glossary of key terms

There are a few terms that crop up regularly when you are working with GTM.

The GTM container

We have already mentioned that to add the tracking tags to your site, you need to add the GTM container script to your website’s code. The container script is a small snippet of JavaScript code - which is provided by GTM - that you need to add high up in the code of each webpage.

Tags, Triggers and Variables

Once the GTM container is added to your site, you use the GTM interface to create the tracking tags within your GTM account to be added to your website.

To build these tags in GTM, you use ‘Triggers’, ‘Variables’ and ‘Tags’. These are the building blocks of tracking tag creation, so it is important that you understand what these are and how these work.

  • Tags are the final snippets of tracking code to be added to your site
  • Triggers determine when each tag will record - you set your trigger as a specific event or set of events, and when a user completes them, your tag will fire. For example, you may want a Google Ads conversion tag to fire when a user completes a purchase, or you may want a tag tracking videos to fire once a user clicks play on a video. Each tag must have a trigger.
  • Variables are the values for each trigger or tag that you can change - they allow you to define when exactly a trigger will fire or what exactly a tag will report on.

For more information see the Google Tag Manager help center.

8. Before you begin

Plan your set up

Once you understand how to use the tool and before you start creating tags in your GTM account, you will need to create a tracking implementation plan.

This plan should cover things like:

Which platform’s tracking codes need to be added to your site (e.g. Google Analytics, Facebook pixel, Google Ads conversions, Hotjar, etc.)

  • Understand how you will implement these
  • Determine what triggers you need to set for these tags (decide if they should go on all pages, like Google Analytics, or only specific pages, such as with the Google Ads conversion event snippet)
  • Have the tracking code for each one (provided by the platform) to hand

Determine the key interactions you need to measure on your site

  • Which interactions are important to record? (e.g. views on pages, video plays, file downloads, etc.)
  • Which interactions provide actionable insights into user intent? (such as purchases, sign ups, specific form completions, etc.)

How you are going to track these interactions - what information do you need to collect?

  • For example, if you are tracking video interactions, do you need to know the video name, or file names of downloads, specific product enquired about, etc.?
  • Do you need any expert support for this?

How you are going to name and structure your GTM tags and parameters for your reports?

  • Determine your naming structure for all of your tags - making sure they are descriptive of what is being tracked so you can easily identify the purpose of the tag
  • Plan the tags, triggers and variables to be tracked for each interaction.
  • Plan the names of the Google Analytics event parameters for each GA event being tracked to ensure they are clear in reports (e.g. if you are creating an event to track video interaction, name the event something that will make sense, such as “video plays”).
Understand PII, privacy and GDPR

When you track users on your website using JavaScript cookies and tracking tags for any tracking platform, it is essential that you understand your legal obligations around data capture. This can be a complex area and you need to get it right. For example, you must gain consent to track users and you must ensure that you are GDPR compliant and follow all privacy and data protection regulations. You can find out more on the Information Commissioner’s Office website.

If you are using Google Analytics you must also ensure that you do not collect any personally identifiable information (PII) such as email address, names, etc. - which you could inadvertently do when you implement GTM, depending on your site’s set up. To understand more about this, see Google’s help information.

9. How to get started

In this section we’ll give a quick outline of the key steps to take to get started with Google Tag Manager and to implement a Google Analytics Universal tracking tag.

1.Set up a GTM account

The first step is to create a GTM account. To do this:

  • Go to the Google Tag Manager site and click on the ‘create account’ link
  • Add your details (naming your account your company name, and your ‘container’ the name of your site) and select your platform type e.g. ‘web’.
2. Add the GTM container script to your site

Once you have created your account and read and accepted the T&Cs, you will be shown a pop up containing your GTM container script snippets which need to be added to your website.

As mentioned, you may require help from a developer to add this container script to your website or web builder platform (unless you are confident that you are able to hard-code it yourself or if your website builder offers built-in integration or simple step-by-step process).

Note, you can click out of this pop up to begin creating tags in your ‘workspace’ before the container script is actually added, as the script is always available in ‘Admin’ > ‘Install Google Tag Manager’ (although the container script will obviously need to be added to your site before you can set any tags you create live).

Once the container script has been added to your script, enter your GTM ‘workspace’ and publish your empty container by clicking ‘submit’ in the top right and following the steps.

3. Create tracking tags

The next step is to create your first tracking tag within your new GTM ‘workspace’ (the area of your GTM account where you create the tags to be added to your site). In this example, we are adding a brand new Google Analytics Universal tag to track pageviews for the first time:

  • In your workspace click ‘add new tag’
  • Give your tag a descriptive name, e.g. “Google Analytics Universal - Pageview - All Pages”
  • Click in the ‘tag configuration’ box and select ‘Google Analytics: Universal Analytics” (if you were adding a Google Analytics 4 tracking tag you would select “Google Analytics:GA4 Configuration”)
  • Select your track type - in this case ‘Page View’ (but if you were setting up Google Analytics (Universal) event tracking to track a specific site interaction you would select ‘event’)
  • Create a new Google Analytics Settings Variable
    ○ Add your Google Analytics ID (which you can get from ‘property’ > ‘tracking info’ > ‘tracking code’ within your Google Analytics account admin section)
    ○ Keep your cookie domain as auto (assuming you are adding Google Analytics for the first time)
    ○ (If you want to add additional settings such as custom dimensions or metrics, content groups etc, add them in ‘more settings’)
    ○ Name your variable - e.g. ‘Google Analytics Universal - Google Analytics Setting”
    ○ Save
  • Select that new Google Analytics Settings variable
  • Click on ‘triggering’ and select ‘All pages’ (we want our Google Analytics tracking script to be present on all pages of our site - if you were tracking a specific event you would select a different trigger).
  • Save the tag

NOTE - when implementing Google Analytics with GTM, make sure that your Google Analytics tracking code isn’t already hard-coded into your site, as adding it again via GTM will record it twice and skew your data.

For more information about how to add Universal Analytics tags to your site for the first time see this Google Tag Manager help article. For information on adding Google Analytics 4 tag via GTM see here.

4. Preview your tag

Before you publish any new tags (which sets them live on your site) it is important that you test the tags that you have created in ‘preview mode’ to ensure that they are recording as expected, and to fix any issues. The GTM Preview mode allows only you (not your other site visitors) to browse your site as if these tags were live.

To test your new Google Analytics tag:

  • Click the ‘preview’ button in the top right of your workspace - this will open two new tabs and a pop up.
  • Enter your site’s url in the pop-up and click ‘connect’ and you will be taken to the first new tab - your site which is now in preview mode. Clicking around your site on this tab will fire the tags that you have created and allow you to see how they work in the ‘debugger’.
  • The other new tab is Google’s Tag Assistant (tagassistant.google.com) - this is the ‘debugger’ screen where you can see all of the information about the tags being fired on your site and check they are firing properly and recording the information correctly.
  • This looks quite technical and can take time to get used to, but you want to look at the ‘tags fired’ section, which will show you which tags were fired.
  • To check your new Google Analytics pageview tag, click on the ‘container loaded’ link on the left. (This shows as soon as your webpage loaded.)
  • Under ‘tags fired’ you should see your new Google Analytics tag (“Google Analytics Universal - Pageview - All Pages”).
  • This means that your tracking tag fired when the page was loaded.
  • Now to double-check the implementation, head to your Google Analytics Universal account and look in the ‘real time’ report - you should see your pageview.

For more information on preview mode and how to test your tags, check out this Tag Manager help article.

5. Publish your new tags

Once you are happy that your tags are working and recording data properly, it is time to publish them on Tag Manager.

Publishing your tags creates a new ‘version’ of your container, which will then be live. Each time you publish new tags, a new version of your workspace will be created. Versions can be really useful as they allow you to revert your tags back to a previous version if you need to fix any errors in implementation.

To publish your new Google Analytics tag:

  • Click ‘submit’ in the top right
  • Select ‘Publish and create version’
  • Add a version name and a version description - make sure this is descriptive of the changes you have made, for example:
    ○ Name “Google Analytics Universal Tag Added”
    ○ Description: “Initial upload of Universal Analytics tracking tag, firing on all pageviews”
6. Check your reports

The final check once you have implemented any tracking tags, is to check that the data is recording as you would expect in the relevant reporting platforms (such as Google Analytics, Facebook Ads, Google Ads, etc).

You should check as soon as data is recorded after the launch of your tags, and then after a week to make sure the data is as you would expect.

If you need to make any changes to your tags, you can then alter them within GTM, and create and publish a new version.

  • Select that new Google Analytics Settings Variable
  • Click on ‘triggering’ and select ‘All pages’ (we want our Google Analytics tracking script to be present on all pages of our site - if you were tracking a specific event you would select a different trigger)
  • Save the tag
  • Click ‘publish’ to set the tag live on your website

Support from DigitalBoost to help you do all of this!

For further advice and support on all aspects of your digital marketing, processes & platforms check out our DigitalBoost programme. Offering free 1:1 consultancy, online resources, training and webinars to help businesses in Scotland develop and grow.

Want to speak with your nearest Business Gateway team?

Your local Business Gateway can offer you free 1:1 advice and online support to help you with anything to do with your business or if you are just thinking about starting up then we can support you with that too.

Fill in the form below and we will get back to you to help.

1. Tell us a bit about your business or idea (such as, sector, stage…) 2. What are your main reasons for contacting us today? 3. Is there anything else we need to know before we contact you?

Enter your postcode

How we use your data

We will use the information you provide to respond to your request, and to provide business advice and support services to you. For more information please view our privacy notice.

You might also be interested in

Artificial Intelligence (AI) – the basics

Discover how AI, particularly Generative AI like ChatGPT, can revolutionise small business operations, from marketing strategies to content creation. Explore its basics, applications, ethical considerations, and practical tips for leveraging its potential.

Pre-launching a new product or business

Many business owners work for months or even years to reach the point they’re finally ready to launch their new business or product, and then suddenly realise they have no clear plan on how to reach people who are ready to hear about it. This is where a pre-launch comes in!

An introduction to social commerce

Social commerce enables businesses to use social platforms to showcase and sell their products and services. Find out what options are available and how to get started.