← Back to Docs

Google Tag Manager

Deploy the SourceTrack tracking pixel site-wide using a Google Tag Manager container.

Who This Is For

This guide is for marketers and website managers who use Google Tag Manager (GTM) to deploy and organize marketing pixels across their site without editing theme code directly.

Key Terms Defined:

  • GTM container — the master script tag you paste on your site that lets you deploy tags from the GTM interface.
  • Custom HTML Tag — a GTM tag type that allows you to copy-paste custom Javascript script code to be injected dynamically.
  • Trigger — a condition in GTM (like "All Pages" or a button click) that dictates when a tag fires.

What You Will Set Up

You will create a Custom HTML tag in GTM, paste our helper script, configure it to fire on initialization, and verify using GTM Preview mode.

Manual recipe: SourceTrack is not distributed as a Google Tag Manager community gallery tag. You paste the tracking snippet into a Custom HTML tag inside your own GTM container — manual setup required.

Steps: GTM Deployment

  1. Open GTM: Log in to your GTM workspace.
  2. Create Tag: Go to Tags and click New.
  3. Configure Tag Type: Click Tag Configuration and choose Custom HTML.
  4. Paste Script: Paste the code below. Remember to changeYOUR_SITE_KEY to your actual public key.
    <!-- Paste this inside a Custom HTML Tag in GTM -->
    <script>
      (function() {
        if (document.querySelector('script[data-site-key]')) return;
        var script = document.createElement('script');
        script.src = 'https://api.srctk.com/tracker.min.js';
        script.setAttribute('data-site-key', 'YOUR_SITE_KEY');
        script.async = true;
        document.head.appendChild(script);
      })();
    </script>
  5. Configure Triggering: Click Triggering and selectInitialization - All Pages (or All Pages (Page View) if Initialization is not available).
  6. Save: Name your tag (e.g. SourceTrack - Base Pixel) and click Save.

How to Verify It Worked

  1. Click Preview in the GTM interface. Enter your live website URL and connect GTM Tag Assistant.
  2. In the Tag Assistant panel, verify that your new SourceTrack - Base Pixel tag has successfully fired.
  3. Open the browser Developer Tools (Network tab) on your site. Filter for track, reload the page, and confirm a call to POST /api/track completes successfully.
  4. Verify your pageviews start logging in the SourceTrack dashboard Event Debugger.

Common Mistakes

  • Forgetting to Publish: Preview mode only works for you. Make sure you clickSubmit → Publish in GTM so the tag is deployed for all your users.
  • Content Security Policy (CSP) Restrictions: If your server enforces a CSP, it may block GTM from injecting external scripts. Ensurehttps://api.srctk.com is allowlisted in your CSP headers under script-src and connect-src.
  • An unmet Consent Settings requirement: if your tag's Advanced Settings has "Require additional consent for tag to fire" checked, and your site isn't actually granting that consent, the tag will silently never fire — no error, no warning, just permanent silence. There's rarely a reason to gate this specific tag behind a consent requirement; if it's checked, it's very likely an accidental misconfiguration. If your tag published successfully and Tag Assistant still doesn't show it firing, check this setting first.

Next Step

You're ready to configure conversions. If you want to track conversion events (like form submissions or button clicks) using GTM triggers, see ourBrowser Conversions guide.