Skip to content

Measurement and analytics

Google Tag Manager

Setup, Consent Mode v2 and common mistakes

On this page

Google Tag Manager (GTM) is Google’s free tool for adding and managing tracking code on a website without changing the website’s own code. With GTM, the marketing team can add a tag for Google Ads or Meta themselves, but the tool does not make the tracking correct on its own. Two common faults are linked to consent: tags that send data without consent, and figures in Google Analytics that are largely modelled.

What is Google Tag Manager?

GTM is a tag management system. Everything that belongs to a website is collected in a container, which consists of tags, triggers and variables (Google). A tag is a code snippet that sends data to a tool, such as Google Analytics 4, Google Ads or an advertising platform. A trigger decides when the tag runs, and every tag must have at least one. Variables capture values such as the page address, a clicked element or an order value.

Through a data layer (dataLayer), the website can also send its own information to GTM, such as product, price and whether the visitor is logged in. This is the safest route for data that will be used in several tags, because the values are then not taken from the page’s appearance, which changes when the website is rebuilt.

GTM is free. There is a paid version, Tag Manager 360, which is part of Google Marketing Platform and offers, among other things, an unlimited number of workspaces (the free version has three), approvals before publishing and a service level agreement.

How to set up Google Tag Manager

Google recommends one container per website. The installation code is placed as high in the page’s head section as possible. Google now shows a single code snippet; older installations have two, with the second in the body section, and they do not need to be replaced (Google).

Changes are made in a workspace and tested in preview mode, which connects the website to Tag Assistant so that you can see which tags run on each page. Every publication is saved as a version, and a faulty version can be rolled back. Always run preview mode before publishing, and write what has changed in the version name.

If you only need to send data to Google’s own services, the Google tag (gtag.js) directly in the code is enough. GTM is needed when tags from other suppliers are to be added.

Web GTM and server-side GTM

GTM comes in two parts. The web container runs in the visitor’s browser, and each tag sends its data directly from the browser to its supplier. Server-side GTM (sGTM) is a server container that runs on a server you control yourselves (Google). The browser then sends data to your own server, and only there is it decided what is passed on and to whom.

Google highlights two advantages: the page runs less code when fewer tags sit in the browser, and visitor data is better protected when it is collected and distributed from an environment you manage yourselves. Best practice is to place the server on a subdomain of your own website. We recommend running it on your own server or with a Swedish hosting provider rather than on Google’s Cloud Run.

In the server container, data can be removed before it leaves your server. With the Transformations feature, you control which parameters each tag can see and exclude sensitive data (Google). This is how personal data is removed, such as an email address that has ended up in a page address, before data is sent to Google or other suppliers. We have extensive experience of installing sGTM servers for clients and help them remove personal data to comply with the regulations.

Modelled figures: when Google Analytics shows visits that do not exist

With advanced mode, Google Analytics 4 fills in the gaps left by visitors who have said no. This requires advanced mode, at least 1,000 events per day from visitors without consent for at least seven days and at least 1,000 users per day with consent for at least seven of the previous 28 days (Google). The model can give a reasonable overall picture, but it can also hide what is happening in a campaign.

We have seen sessions on a product page increase around 40 times in Google Analytics compared with the previous month. A comparison with the raw data in BigQuery showed that around 95 per cent of the sessions in Google Analytics were modelled, that over 90 per cent of the visitors to the page had declined cookies and that the real increase was around 5 times. The cause was an advertising campaign with low-quality traffic, and the model had made it hard to detect.

On another website we have analysed, the figures for large campaigns were 30 to 70 per cent higher in Google Analytics than in the BigQuery export. The model also affects different metrics to different degrees: sessions can differ sharply between measured and modelled data, while leads, for example, were barely affected in that case. So compare the figures in Google Analytics with the BigQuery export, broken down by consent status, before drawing conclusions about a campaign.

How we can help you with Google Tag Manager

  • Audit: a review of the container, focusing on consent, duplicate tags and tags without consent requirements.
  • Consent Mode: connecting the consent management tool and GTM, with tests of all states.
  • Server-side: installing and running sGTM servers, with personal data removed before data is passed on.
  • Data quality: a comparison between Google Analytics and the BigQuery export, so that you know which figures are measured.

If you measure with Matomo instead of Google Analytics, there is more on the Matomo page, and the full picture is described under web analytics. Want to know whether your container respects consent? Contact us, and we will start with a review.

Want to know where you stand today?

Call us, or fill in the form and we will get back to you.