Setting up Google Tag Manager and GA4 for your website
Google Tag Manager is the tool that adds tracking code to a website without changing the site's own code, and GA4 is the service that stores and reports the data collected. webrocks sets up the container, the GA4 property and custom events via the dataLayer, and checks everything in preview mode before any change is published.
This text was written with the help of artificial intelligence. Statements about platforms are based on the official documentation linked in the article. Tomáš Hanus is responsible for the content, webrocks.cz@gmail.com.
- Who it is for
- For website owners who want to know what visitors actually do on their site, or who no longer trust the numbers from their current tracking.
- What you get
- A configured GTM container and GA4 property with custom events, verified in GTM preview mode and DebugView, plus an overview of what is tracked and where.
- Price
-
- Tracking: Scope-based
Indicative, based on the pricing. The price depends on scope; webrocks prepares a specific offer based on your brief.
What Google Tag Manager and GA4 are and when to set them up
Google Tag Manager (GTM) is a tag management system: it lets you add and change tracking and advertising code (tags) without touching the website’s code. Tags, the rules that fire them (triggers) and variables make up a container, which is installed on the site once.
GA4 (Google Analytics 4) is the service that receives, stores and reports the data. GTM measures nothing itself; it only decides when each tag fires and with which values.
A setup makes sense for a new website, for a site with no tracking at all, and for a site where tracking exists but nobody is sure what it counts. Old Universal Analytics code no longer measures anything: standard UA stopped processing data on 1 July 2023.
Who this is for and who it is not for
It fits when:
- you want to track the actions that matter on your site with the parameters you need, such as a specific form submission or a phone or email click,
- you are planning to advertise and will need reliable events that can become conversions,
- the numbers in GA4 do not add up and you need an audit of the existing tracking.
It does not fit when all you need is visit counts and your most visited pages. GA4 measures that without GTM or custom events, along with basic actions from enhanced measurement such as outbound clicks and file downloads.
If you run an online shop and mainly care about purchases, baskets and revenue, that is separate work covered in GA4 ecommerce tracking. This page is about the foundation that ecommerce tracking is built on.
GA4 directly, or through Google Tag Manager?
GA4 can be added to a website in two ways: directly with the Google tag (gtag.js), or through a GTM container. According to Tag Manager Help, the Google tag can only send data to Google products, while GTM also manages third-party tags and custom code.
GTM makes sense when:
- you want custom events and the freedom to change them without redeploying the website,
- the site will run other tags too, such as advertising pixels,
- you need to test changes in preview mode first and keep a version history you can roll back.
On a simple site that only measures traffic, it is unnecessary: the Google tag or the platform’s native integration is enough.
A common mistake is combining both: GA4 sits in the website code and in GTM at the same time. Page views and events can then be sent twice and the reports are inflated. Shoptet warns about this explicitly in its help centre and recommends keeping a single installation method.
How the setup works
1. Agreeing what to measure
First, list the actions that matter on your site and what you want to see in GA4. Otherwise it is easy to track everything and use none of it.
2. Accounts, container and GA4 property
The GA4 and GTM accounts are created or checked and the container is installed on the site. On Shoptet the container ID goes into Integrations → Google → Tag Manager; on WordPress a plugin such as GTM4WP can be used. In the GA4 property, data retention and key events are configured.
3. dataLayer and custom events
Where GTM cannot read what it needs from the page, the website sends values to the data layer (dataLayer) with dataLayer.push(). GTM reads the events from there and passes them on to GA4. Event and parameter names follow one consistent convention.
4. Verification and publishing
Every change is checked in GTM preview mode, which shows which tags fired and with what data. Incoming events are then checked in GA4 DebugView. Only after that is the container published as a new version that can be rolled back to later.
What you get
- a GTM container with tags, triggers and variables named so that someone else can find their way around,
- a GA4 property with data retention and key events configured,
- custom events (such as a form submission or a contact click) and a description of what the site sends to the dataLayer,
- verification in GTM preview mode and DebugView,
- for an audit, a list of findings with a recommended order of fixes.
What to watch out for
Default data retention is 2 months
GA4 keeps data for 2 months by default, and the change has to be made manually in the admin. A standard property allows at most 14 months, and the setting does not affect standard aggregated reports, mainly explorations. So the default can easily go unnoticed until someone needs to compare a longer period.
GA4 has key events, not conversions
In GA4, important actions are called key events. The word conversion is reserved for Google Ads, where a key event can be turned into a conversion. A standard property allows at most 30 key events, so it pays to mark only the ones that really mean something.
The dataLayer must not be overwritten
According to Google’s documentation, the data layer is created as high in the code as possible, above the container, with window.dataLayer = window.dataLayer || [];. If a script later reassigns it, tags may not fire. The symptom is that some events are silently missing.
Consent and site speed
GA4 uses analytics cookies. Section 89(3) of the Czech Electronic Communications Act requires prior consent for storing information on a user’s device and exempts only technical storage. The Czech data protection authority (ÚOOÚ) explicitly lists analytics and statistics among the purposes covered by consent since 2022, so under this reading GA4 needs prior consent in the Czech Republic. Passing the cookie banner choice to Google tags is what Consent Mode v2 handles. And every extra tag in the container is one more script; according to web.dev, third-party scripts can slow a site down. If the site is slow, a website speed audit helps.
How much GA4 and GTM setup costs
The price list shows tracking as scope-based, with an indicative hourly rate from 500 CZK/hr. The price mainly depends on:
- how many custom events are needed and whether the site can send them to the dataLayer itself, or its code has to be changed,
- whether tracking is built from scratch or existing tracking has to be cleaned up first,
- whether ecommerce, Google Ads conversion tracking or Consent Mode is added on top of the foundation.
The scope is agreed after a short enquiry.
Frequently asked questions
Do I need Google Tag Manager if I already have GA4?
Not always. GA4 alone measures traffic. GTM pays off for custom events, other tags, or changes without touching the website code.
What is the dataLayer?
The data layer is an object on the page through which the website passes values to GTM and the Google tag. The site sends events and values to it with dataLayer.push(), and GTM reads them from there.
How do I check that tracking works?
GTM preview mode shows which tags fired during your visit and with what data. In GA4, DebugView then shows whether the events actually arrived and carry the right parameters.
Why are events sent to GA4 twice?
Most often because GA4 is installed twice: in the website code or through the platform’s integration, and in GTM as well. The fix is to keep just one method.
Who should own the GA4 and GTM accounts?
The recommendation is that the website owner owns both the GA4 and GTM accounts directly and the supplier only has access to them. If you change suppliers, you keep your data and your setup.
Sources
- Tag Manager Help: Introduction to Tag Manager
- Analytics Help: Google Analytics 4 has replaced Universal Analytics
- Analytics Help: Enhanced measurement events
- Tag Manager Help: Google Tag Manager vs. gtag.js
- Shoptet Help (Czech): Google Analytics setup
- Shoptet Help (Czech): Google Tag Manager
- WordPress.org: GTM4WP plugin
- Google for Developers: The data layer
- Tag Manager Help: Preview and debug containers
- Analytics Help: Monitor events in DebugView
- Tag Manager Help: Publishing, versions, and approvals
- Analytics Help: Get started with Explorations
- Analytics Help: Data retention
- Analytics Help: Conversions vs. key events in Google Analytics
- Analytics Help: [GA4] Configuration limits
- Zákony pro lidi (Czech): Act No. 127/2005 Coll., on Electronic Communications
- Czech Data Protection Authority (ÚOOÚ, Czech): Cookies only with consent from 2022
- web.dev: Load Third-Party JavaScript