The short answer
Put one Google Tag Manager container on every page, as high in the head as you can. Inside it, add one Google tag with your GA4 measurement ID, and remove every other copy of GA4 from the site. Before you collect real data, set data retention, define your own office traffic as internal, and review enhanced measurement. Then test in preview mode before you publish anything.
Tag Manager is worth it even on a small site. It lets you add, change and test tags without touching the site code each time, and it is where the consent rules in chapter 3 live.
Own the accounts first
This step has nothing to do with code, and it causes more trouble than any tag. The GA4 property, the Tag Manager account and the Search Console property should belong to your company, under a company Google account, not to a freelancer or an agency.
- Create the accounts under a shared company login, or make sure at least two people inside the company are admins.
- Give your agency or developer their own access, at the level they need, so you can remove it later.
- Write down who has access to what, in the same sheet as your measurement plan.
- Do it before launch. Moving a property's history to a new owner later is much harder than adding a user now.
When we set up tracking for a client, we work inside their accounts with our own logins. When the work ends, they remove us, and nothing breaks.
Set up GA4 before data arrives
Create a GA4 property and a web data stream for your domain. Then change these settings on day one, because several of them only apply to data collected after the change.
| Setting | Where | What to do |
|---|---|---|
| Data retention | Admin, data retention settings | Standard properties can keep event data for 2 or 14 months. Pick 14. Google says this only affects explorations and funnel reports, not standard reports, but you will want explorations later. |
| Internal traffic | Data streams, your web stream, Configure tag settings, Define internal traffic | Add your office IP addresses. GA4 labels matching traffic with a traffic_type value. |
| Data filter | Admin, Data collection and modification, Data filters | Create an Internal Traffic filter set to Exclude. Leave it in Testing first. |
| Enhanced measurement | Data streams, your web stream | Review each event in the list. Leave form interactions on until you decide, in chapter 4. |
Be careful with the filter. Google's internal traffic help explains three states. Testing labels matching data so you can check it. Active applies the filter to incoming data, and the change is permanent: excluded data is never processed. Inactive turns it off. It can also take 24 to 36 hours to take effect. Leave it in Testing for a few days, check that only your own visits are caught, then switch it to Active.
The data retention details are on Google's data retention page. Longer periods are only for Analytics 360.
Install the container
Google's install guide says to paste the first code block as high in the <head> as possible. Where you do that depends on the platform.
Webflow. Go to Site settings, then the Custom code tab, and paste it into Head code. That code appears before the closing head tag on every page. Webflow's custom code help says custom code needs a paid Workspace or an active site plan, and that the Head code box takes up to 50,000 characters. Webflow support does not help with custom code, so keep the snippet exactly as Google gives it.
Astro. Put the snippet in the shared layout that renders the head for every page, so no page can miss it. If your site sends a Content Security Policy, the policy must allow the Tag Manager script and the hosts your tags call. On our own Astro site, a build step adds the hash of each inline script to the policy, and Google hosts are only allowed when an analytics ID is set.
Both. Most consent setups need the container to load in a controlled way. If you use a consent tool, read chapter 3 before you paste anything, because the order of scripts is the part that most often goes wrong.
Decision rule One container per site. If a second container or a second GA4 snippet turns up, remove it rather than working around it.
Add GA4 inside Tag Manager
In your container, add a Google tag with your GA4 measurement ID (the one that starts with G), and fire it on all pages. That gives you page views and enhanced measurement. Your own events, from chapter 4, are GA4 Event tags that use the same measurement ID.
Then go looking for other copies of GA4, because a second copy counts every visit twice. These are the places we find them most often:
| Where GA4 hides | How to check |
|---|---|
An old gtag.js snippet in head or footer code | Search the site code and the page settings for G- |
| A platform setting or app that adds Google Analytics for you | Check site settings, installed apps and integrations |
| An embed element on one page | Search embeds for googletagmanager |
| A second Tag Manager container | Search the page source for GTM- |
| A booking or chat tool that sends its own GA events | Read that tool's analytics settings |
The quickest check: open the live site, open your browser's Network tab, filter for collect, and load one page. You should see one page view request to GA4, not two.
Workspaces, versions and notes
Tag Manager keeps every published version of the container. Use that.
- Name every version. When you publish, write what changed and why, for example "Add call_booked from Cal.com embed". Six months later, this is the only record of when a number started or stopped.
- Test before you publish. Preview mode, covered in chapter 6, runs your draft in your own browser only.
- Keep it tidy. Name tags, triggers and variables the same way:
GA4 event, generate_lead,CE, lead_sent,DLV, form_name. A container nobody can read is a container nobody fixes. - Delete what you do not use. Paused tags and old triggers are where mistakes come from.
Setup checklist
- GA4 property and web stream created under a company account.
- Data retention set to 14 months.
- Internal traffic defined, filter in Testing, then Active once checked.
- One Tag Manager container, high in the head of every page.
- One Google tag with your measurement ID, firing on all pages.
- No other GA4 snippet, app or container anywhere on the site.
- Enhanced measurement reviewed.
- Access list written down, with at least two company admins.
- First version published with a clear note.
Once this is done, the site is counting page views and the basic events. Nothing marks a lead yet. That comes after consent, because the order matters.


