Quick answer: enter your Google Analytics 4 measurement ID (it starts with G-) and copy the Google tag code. Paste it right after the opening head tag on every page, or use your site builder’s Google Analytics setting instead.
Google Tag Generator
Google tag (gtag.js) and Tag Manager install code. Free, private, no sign-up.How to use the Google Tag Generator
- Paste your ID: G- for Google Analytics 4, AW- for Google Ads, or GTM- for Tag Manager.
- Turn on consent mode defaults if your site shows a cookie banner.
- Copy the code.
- Paste the head code right after the opening
<head>tag on every page. For Tag Manager also paste the second snippet right after<body>.
Which ID do I have?
| ID starts with | Product | Where to find it |
|---|---|---|
| G- | Google Analytics 4 (measurement ID) | Admin, Data streams |
| AW- | Google Ads conversion tag | Tools, Conversions |
| GTM- | Google Tag Manager container | Top of the Tag Manager workspace |
Add the tag once. Installing both a plugin tag and a pasted tag for the same ID counts every visit twice.
Where to paste the code
Google recommends placing the Google tag immediately after the opening head tag on every page you want to measure. Tag Manager has two parts: a script for the head and a noscript snippet right after the opening body tag. The generator shows each piece separately so you know exactly where it belongs.
WordPress options
- A header and footer plugin: paste the code into the header box once and it loads on every page.
- Site Kit by Google: connects Analytics and adds the tag without copying code.
- Your theme: some themes have a field for head scripts. Avoid editing theme files directly, because updates can erase your changes.
Do not install it twice
The most common mistake is adding the Google tag directly and also through Tag Manager or a plugin. That sends every page view twice and doubles your numbers. Pick one method. If you use Tag Manager, set up the Google tag inside it and remove any direct gtag.js code.
Check that it works
- Open your site in a private window.
- In Google Analytics, open the Realtime report and confirm your visit appears.
- Use Google Tag Assistant to see which tags fire on the page.
- Click a few pages to make sure the tag loads everywhere, not only on the home page.
Consent and privacy
If you have visitors from the European Economic Area or the UK, you need a consent banner, and Google requires consent mode signals for some advertising features in that region. The generator can include default consent settings, which your banner then updates when a visitor makes a choice. Make sure your privacy policy explains what you measure. Pair your tracking with clean campaign links from the UTM builder so you can see which posts and ads bring visitors.
gtag.js or Tag Manager?
Use the plain Google tag when you only need Google Analytics or a single Google Ads account, because it is one snippet with nothing extra to manage. Choose Tag Manager when you expect several tags, such as Analytics, Ads conversions and other marketing pixels, or when someone else will manage tracking without editing the site. Tag Manager adds one layer of setup, but later changes happen in its dashboard instead of in your site code. Either way, keep a note of which IDs are installed where, so a future developer does not add a second copy by mistake.
A short checklist kept with your site notes saves hours of confusion when numbers suddenly double or drop.
After you add the tag
- Open your site and check the Realtime report in Google Analytics to see your visit.
- Add the tag only once. Two copies count visits twice.
- If you use Google Tag Manager, add GA4 inside Tag Manager instead of pasting this code.
Frequently Asked Questions
What is the Google tag?
Should I use gtag.js or Tag Manager?
What is consent mode?
What does the G- ID mean?
A G- ID is a Google Analytics 4 measurement ID. AW- IDs belong to Google Ads and GTM- IDs to Tag Manager containers.
Will the Google tag slow down my site?
The tag loads asynchronously, so its effect is small. Too many extra tags and scripts are a bigger cause of slow pages.
Where do I find my GA4 measurement ID
Is the Google tag the same as gtag.js
Sources
- Google Tag Platform: install the Google tag
- Tag Manager Help: install a web container
- Google Tag Platform: set up consent mode
- Analytics Help: find your Google tag ID / measurement ID
Checked November 2026. Platforms change their rules, so check the linked page if a number looks different in your app.