Google Tag Manager Snippet and dataLayer Builder

Enter your GTM container ID to get the head and body snippets, set consent mode v2 defaults by region, copy dataLayer push templates for forms, clicks and purchases, and tick off a checklist.

브라우저에서 실행됩니다. 파일은 기기 밖으로 나가지 않습니다. 확인하는 방법 보기

…

사용 방법

  1. 1
    Enter your container ID

    Type the GTM-XXXXXXX ID from Tag Manager and keep or change the dataLayer name.

  2. 2
    Copy the snippets

    Copy the head code and the body code and paste them into your site template.

  3. 3
    Set consent defaults

    In Consent mode, choose granted or denied for each type, regions and wait time.

  4. 4
    Wire the banner

    Copy the consent update call into your cookie banner's accept action.

  5. 5
    Add dataLayer pushes

    In dataLayer pushes, pick a template, copy it and adapt the values.

  6. 6
    Work through the checklist

    Tick each step as you test it and download the checklist for your records.

이 도구 소개

Installing Google Tag Manager looks simple, two snippets of code, but small mistakes cause months of bad data: the snippet in the wrong place, two containers on one page, consent defaults loaded after the tags, or ecommerce data leaking from one event to the next. This builder produces everything a site needs, filled in with your own container ID. It writes the head snippet and the noscript body snippet, with an optional custom dataLayer name. A consent mode tab builds the version 2 defaults, with all seven consent types, an optional list of regions, the wait time for your cookie banner, ads data redaction and URL passthrough, and the matching update call for when a visitor accepts. A templates tab gives ready dataLayer pushes for form submissions, button clicks, purchases, sign-ups, file downloads and page data. A checklist of ten installation steps keeps track of what has been done and can be downloaded for the developer.

The two snippets

Tag Manager needs a script in the head of every page, as high as possible, so tags can fire early, and a noscript iframe immediately after the opening body tag for browsers without JavaScript. The container ID, GTM- followed by letters and numbers, is shown at the top of your Tag Manager workspace. The builder checks the format and fills it into both snippets.

Consent mode v2

Where the law requires consent before cookies are used, as in the European Economic Area and the UK, Google's consent mode tells tags how to behave before and after the visitor chooses. Version 2 has four signals that matter for advertising and analytics: ad_storage, ad_user_data, ad_personalization and analytics_storage, plus functionality, personalisation and security storage. The defaults must be set before the container loads, usually as denied, and updated by your cookie banner when the visitor accepts. The region option applies the defaults only to listed countries or states. wait_for_update gives the banner time to load a saved choice.

dataLayer pushes

The dataLayer is a JavaScript array that passes information from your site to Tag Manager. Each push with an event key can fire a Custom Event trigger, and its other keys can be read with Data Layer Variables. For ecommerce, Google recommends pushing ecommerce: null before each new ecommerce event so items do not carry over. The templates follow that pattern.

Worked example

A shop with container GTM-ABC1234 serving visitors in the UK and EU sets every consent type to denied except functionality and security storage, with a 500 ms wait. The builder outputs the consent block followed by the head snippet for the head of the template, the noscript snippet for the body, and a consent update call for the banner's Accept button. A purchase push with a cleared ecommerce object goes on the order confirmation page.

Limits

The builder writes code; it does not install it, configure tags in Tag Manager, or decide what your privacy law requires, and it is not legal advice. Use a consent management platform where required, test everything in Tag Assistant preview mode and never send personal data through the dataLayer.

풀이 예시

GTM-ABC1234 with consent defaults denied for ads and analytics, region GB, wait_for_update 500, then head and body snippets.

한눈에 보기

자주 묻는 질문

Where do the GTM snippets go?

The script goes as high as possible inside the head of every page; the noscript iframe goes immediately after the opening body tag.

What is consent mode v2?

Google's way for tags to respect a visitor's cookie choices. Version 2 adds the ad_user_data and ad_personalization signals, which Google requires for advertising in the EEA.

Should the defaults be denied?

Where prior consent is required, yes: deny by default and update to granted when the visitor accepts. Elsewhere, follow the law that applies to your site.

Why push ecommerce: null?

The dataLayer keeps values between pushes. Clearing the ecommerce object stops items from one event appearing in the next.

Can I rename the dataLayer?

Yes, but only if you need to; the builder uses the name in every snippet and template. Most sites keep dataLayer.

Does the tool send my container ID anywhere?

No. Snippets are generated in your browser and saved only on this device.

완전 무료요금 없음, 가입 없음
파일은 비공개로 유지됩니다모든 작업이 브라우저 안에서 이루어집니다
내 언어로 쉽게여러 언어로 제공