HomeBlogBenefits of implementing Google Analytics with Google Tag Manager
The benefits of implementing Google Analytics with Google Tag Manager – Our step-by-step guide
created on: 18/11/2020
Google Analytics is an extremely useful tool to track users’ interactions on your website: it allows you to understand what they do on your platform and where they came from. Implementing it correctly can however be challenging, so we thought of sharing some tips that will hopefully help you in this process.
There are two ways you can set up Google Analytics on your website:
You can add the Global Site Tag (gtag.js) for each interaction you want to track on your website
You include the Google Tag Manager scripts in your website
Option 1 – Global Site Tag
With this method, you need to add a Google Analytics code snippet, known as Global Site Tag or gtag.js, to every page of your website. If you need to track events, for example click interactions with the top banner of your website, you’ll have to add another specific code snippet to track those events as well. As you can imagine, if you have a large website or many components you want to track, this method can become quite time-consuming.
Option 2 – Google Tag Manager scripts
The second method, using Google Tag Manager, is usually the preferred option as you only need to add two pieces of code to each page that you want to track.
Google Tag Manager is a free tag management tool that, with an easy to use user interface, allows you to implement various tags on your website, without having to modify the source code of your website.
You might be thinking: “So, what’s the difference if you always have to add some code to the source pages of the website?” Well, once Google Tag Manager is successfully implemented on the website, you don’t have to tweak or change the code any more and if you are using any third party software or platform on the website, for example Facebook Pixel to track conversions, you can track and deploy them onto the website via Google Tag Manager without having to worry about modifying the code of your website. Instead, if you implement the Global Site Tag, you need to maintain the code and change it every time you want to make any amendments.
Using the latter method, you will only need to add the Google Tag Manager code without worrying about the Global Site Tag script. If you end up adding it by mistake, just please make sure you remove it otherwise the number of page views will be doubled.
Well, by now it should be clear that our preferred method is the second one, so please follow along in case you would like to give it a go!
The first step is to create an account on Google Tag Manager and Google Analytics. Within Google Tag Manager, create an account and click on create a new container
Select container type, which will be a “web container” in this case. After this, some code snippets will pop up.
As described in the pop up, you will need to add the first piece of code towards the end of the < head > tag of your HTML file and then do the same for the other code snippet, but please try and place it as high as possible in the < body > tag.
These two code snippets need to be placed in all the pages that you want to track.
In case you’re using a website builder like Wix or Weebly, go to your settings and usually in the marketing or SEO section, you’ll be able to add any appropriate snippets for each page, without having to touch the source code of your website. If you are using a WordPress website, you can use the Tag Manager plugin, following a very similar process to the one we've just described.
Once you’ve added Google Tag Manager code, you can start creating your first tag! Go to the “Tags” section, click new tag and select Google Analytics.
Select “Pageview” and add your Google Analytics property. To find it, you need to go to Google Analytics, create a property – you’ve probably created it already – and you should find a code that starts with “UA-“, then click on create "new variable" and select "Google Analytics settings". Finally insert the code that starts with "UA-" and save.
Now, you’ll need to add a trigger condition, which is the condition on which this tag should send information to your Google Analytics account. For this example, under the tag, you can see the trigger area, let’s select the plus icon on the right and add the default trigger for all pages, as shown below.
This means that this tag will send information at every page view.
Rename and save the tag. Then click preview mode and a new debug page should open. Insert your website in the text box and you'll be able to use the debug view.
On the new page opened, on the summary tab, you should be able to see the tag that you’ve just created. If you can see it, then that’s great, this means it works! To double-check that it works correctly, you can go to the “Real time” section of Google Analytics and you should see a new user visiting the website! In case you would like to test it even more in depth, you can add a Chrome plugin called “Google tag assistant” and check if the tags are working correctly.
Return to Google Tag Manager and click submit in the top right corner.
Now pat yourself on your back as you have just added Google Analytics to your website with Google Tag Manager!
For more detailed information, you can see Google’s official documentation here.
Implementing Google Tag Manager or Google Analytics on your website still seems too daunting? We are here to help – get in touch for a free consultation or drop us a message at firstname.lastname@example.org