Install GroundTruth Pixel with Google Tag Manager (GTM)

Overview

Google Tag Manager (GTM) is a free tool that helps you easily manage marketing and analytics tags on your website or app without modifying code directly. GTM embeds a single container code on your website that dynamically loads tags based on rules you define.

Key GTM Components

  • Tags: Code snippets that fire on your website for tracking (e.g., GroundTruth Base Pixel).
  • Triggers: Rules that define when a tag fires (e.g., when a specific page loads).
  • Variables: Dynamic values used in triggers/tags (e.g., page URL).

Step 1: Create RegEx Matching Trigger

It’s best practice to use RegEx matching for your GroundTruth Pixel trigger.

  1. In GTM, navigate to Triggers in the left menu and click New.
  2. Name the Trigger (e.g., GroundTruth - Page URL RegEx Match).
  3. Click Trigger Configuration and select Page View.
  4. Change the selection from "All Page Views" to Some Page Views.
  5. Set the rule to Page URL > matches RegEx and paste your pattern (see reference table below).
  6. Click Save.

RegEx Pattern Reference

Google Tag Manager uses the RE2 regex engine. Replace example.com with your actual domain name.

Use Case RegEx Pattern Explanation
Target All Pages of a Domain ^https://(www\.)?example\.com The ^ anchors the match to the start of the URL, while (www\.)? makes "www." optional so it captures your domain regardless of how it’s typed.
Target the Homepage Only ^https://(www\.)?example\.com/?$ The /?$ pattern ensures the URL match ends after the domain, allowing for an optional trailing slash but blocking subfolders.
Target a Specific Subdomain ^https://shop\.example\.com Anchors the match to only trigger for URLs starting with that exact subdomain (e.g., shop.example.com).

Step 2: Install the GroundTruth Pixel Code (Base Pixel)

Add the GTM container to your site, onto all pages that you wish to track. If GTM has not been installed, follow Google’s setup guide.

  1. In GTM, navigate to Tags in the left menu and click New.
  2. Click into the Tag Configuration box and select Custom HTML.
  3. Copy your auto-generated Base Pixel code snippet from Ads Manager (Step 6: Measurement) and paste it into the HTML text box.
  4. Click Triggering and select the Regex Page View Trigger created in Step 1.
  5. Name the tag (e.g., GroundTruth Base Pixel).
  6. Click Save.
💡 Note: The Base Pixel automatically captures standard engagement actions (pageviews, sessions, unique users, and time-on-site).

Step 3: Install Custom Event Codes (Optional)

To track post-click conversion actions (such as purchases or form fills), create secondary Custom HTML tags in GTM attached to specific event triggers.

🛍️ Add to Cart

This code enables you to track any action related to an add to cart event on your website.

  1. Create Trigger: Go to Triggers > New. Select a trigger type matching your cart action (e.g., Click - All Elements or Custom Event named addToCart). Name it (e.g., Add to Cart Trigger).
  2. Create Tag: Go to Tags > New > Custom HTML. Paste the following snippet into the HTML box:

    <script>
    gtpx('cart',{amount: {{Cart Value}}});
    </script>

    Replace {{Cart Value}} with your GTM variable or a numerical value.

  3. Attach Trigger: Click Triggering, select your Add to Cart Trigger, name the tag (e.g., GroundTruth Pixel | Add to Cart), and click Save.

💳 Purchase

This code enables you to track any action related to a purchase event on your website.

  1. Create Trigger: Go to Triggers > New. Select a trigger type matching your order confirmation page (e.g., Page View on /thank-you). Name it (e.g., Purchase Trigger).
  2. Create Tag: Go to Tags > New > Custom HTML. Paste the following snippet into the HTML box:

    <script>
    gtpx('purchase',{amount: {{Purchase Value}}});
    </script>

    Replace {{Purchase Value}} with your dynamic GTM purchase variable or keep it as {{Purchase Value}}.

  3. Attach Trigger: Click Triggering, select your Purchase Trigger, name the tag (e.g., GroundTruth Pixel | Purchase), and click Save.

📝 Conversion

This code enables you to track any conversion action related to a signup or form submission on your website.

  1. Create Trigger: Go to Triggers > New. Select a trigger type matching your form completion page or button click (e.g., Page View on a confirmation page or a Form Submission trigger). Name it (e.g., Signup Trigger).
  2. Create Tag: Go to Tags > New > Custom HTML. Paste the following snippet into the HTML box:

    <script>
      //Track conversion
      gtpx('conversion',{label: 'my_goal_name'});
    </script>

    Replace my_goal_name with your custom goal name string in the label field (e.g., newsletter_signup).

  3. Attach Trigger: Click Triggering, select your Signup Trigger, name the tag (e.g., GroundTruth Pixel | Lead Signup), and click Save.

Step 4: Verify & Publish

  1. Click Preview in the top right corner of GTM to enter Tag Assistant debugging mode.
  2. Enter your website URL to confirm your GroundTruth tags fire successfully on the intended pages.
  3. Once verified, click Submit / Publish in GTM to make your changes live.

Follow our [Validating & Troubleshooting Your Pixel Setup] guide for detailed inspection steps using Chrome DevTools.


⚠️ Using Classic Ads Manager? Setup workflows and UI views in this guide reflect the updated platform experience. If you are using our legacy interface, please contact a GroundTruth representative for guidance.

 

Frequently Asked Questions

  1. How do I generate the pixel? Your Base Pixel snippet is automatically generated with your unique account identifier (gtid) inside Ads Manager at Step 6 (Measurement) during campaign creation.
  2. Do I need to generate a new pixel for every campaign? No. Pixels are managed at the account level and can be reused across campaigns driving traffic to the same domain.
  3. Why does exact URL matching fail in GTM? Ads Manager appends query parameters (e.g., ?rid=123&campaignId=456) to landing page URLs to measure web engagement. Exact match rules fail when these parameters are present, whereas RegEx matching allows the pixel to fire reliably.
  4. Do I need to select "Support document.write" when configuring my tag? No. The GroundTruth Pixel loads asynchronously using modern web standards. Leave "Support document.write" unchecked.
  5. What if my site uses a 3rd-party checkout platform? If users are redirected to an external domain during checkout, tracking data may be lost. We recommend directing ad traffic and conversion tracking to pages hosted on your primary domain whenever possible.

Need Help?

For additional support and to ensure your campaign is set up for success, please reach out to your dedicated GroundTruth representative, or contact our Self-Serve team directly at selfservehelp@groundtruth.com.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.