Google Tag Snippet Generator — gtag.js, GA4, Google Ads and Tag Manager

Enter your GA4 measurement ID, Google Ads ID or Tag Manager container ID and get install code that is ready to paste — with Consent Mode v2 defaults, cross-domain linking, debug mode, manual page views and cookie settings switched on only when you need them.

Runs in your browserUpdated

In the <head>, as high as possible

Right after the opening <body> tag

In Webflow paste the head code in Site settings → Custom code → Head code. Using the cookie banner generator? Put its first snippet above this one.

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Google Tag Snippet Generator

  1. Choose Google tag to install GA4 or Google Ads directly, or Tag Manager if you manage tags in a GTM container.
  2. Enter your IDs — find the GA4 one in Admin → Data streams, and the container ID at the top of Tag Manager.
  3. Keep Consent Mode v2 defaults on if you show a cookie banner, and add only the options you need.
  4. Paste the head code into every page (Webflow: Site settings → Custom code), publish, and check the Realtime or DebugView report.

What each option adds

  • Consent Mode v2 defaults — gtag('consent', 'default', …) sets ad_storage, ad_user_data, ad_personalization and analytics_storage to denied before any tag runs, with wait_for_update so a banner has time to load. Your banner then calls gtag('consent', 'update', …).
  • Debug mode — debug_mode: true sends events to DebugView in GA4. Turn it off before you go live, or the debug traffic is mixed into reports for a few minutes at a time.
  • Manual page views — send_page_view: false stops the automatic page view, for single-page apps that send page_view on every route change.
  • Cross-domain tracking — linker.domains adds the _gl parameter to links between your domains, so one visit across them stays one session. You also need the domains listed in the GA4 data stream settings.
  • User ID — user_id joins one person’s visits across devices. It must be your own internal ID; Google’s policies forbid sending emails, names or other personal data.

Google tag or Tag Manager?

The Google tag (gtag.js) is the shortest way to add GA4 or Ads to a site. Tag Manager loads a container you edit in its web interface, so marketers can add tags, triggers and pixels without touching the code — the better choice when a site has many tags. Use one or the other for the same GA4 property, not both, or every page view is counted twice. Then send events with the GA4 Event Code Generator and check that tags load with the Tracking Tag Checker.

Also searched as: gtag snippet generator, google tag code generator, ga4 install code, gtag.js code, google tag manager snippet, gtm install code, google ads conversion tag, consent mode default code.

Tools that pair well with the Google Tag Snippet Generator

  • Event Tracking Script Generator — Track button clicks, links and form submits by adding attributes instead of code: data-track="sign_up_click" plus optional data-track-* parameters.
  • Cookie Consent Banner Generator — Add a cookie consent banner to any site — Webflow, WordPress, Shopify or plain HTML — without a paid plugin.
  • UTM Builder — Add utm_source, utm_medium, utm_campaign and friends to any link, see which GA4 channel the visit will land in, and tag a whole list of URLs at once.
  • GA4 Request Decoder — Debug Google Analytics 4 without guesswork.

Frequently asked questions

Where do I find my GA4 measurement ID?
In Google Analytics go to Admin → Data streams, open your web stream and copy the ID that starts with G-.
Can I install both GTM and gtag.js?
You can, but don’t load the same GA4 property in both, or page views are counted twice. If you use Tag Manager, add GA4 inside the container instead.
Does this code respect cookie consent?
With Consent Mode v2 defaults on, Google tags store no cookies until your banner sends a consent update. Without a banner that sends updates, Analytics stays in cookieless mode.
How do I check the tag works?
Turn on debug mode and open Admin → DebugView in GA4, or watch the Realtime report. The Google Tag Assistant browser extension shows every tag a page loads.
Can I install Google Tag Snippet Generator as a web app and use it offline?
Yes. Google Tag Snippet Generator is an installable web app (PWA) — installed from your browser, not downloaded from an app store. Click Install app at the top of this page in Chrome or Edge (Windows, macOS, Linux, ChromeOS) or on Android, use Share → Add to Home Screen on iPhone and iPad, or File → Add to Dock in Safari 17+ on a Mac. It then opens in its own window with its own icon, and because it runs entirely in your browser it keeps working offline. Firefox on desktop can’t install web apps. How installing works.

Related tools