Install GroundTruth Pixel in WordPress

This guide provides step-by-step instructions on how to implement the GroundTruth pixel on your WordPress site. While a plugin is not required to add custom scripts to WordPress, it is a convenient option for users who prefer not to edit theme files directly.

About WordPress Installation

There are two ways to manage your code in WordPress:

  1. Native (No Plugin): Many modern themes (Astra, Divi, Genesis) have a "Header/Footer" or "Custom Code" section in the Theme Customizer.
  2. Plugin-Based: Using a plugin like WPCode (Insert Headers and Footers) allows you to manage snippets in a dedicated dashboard without touching your theme’s header.php file. (Note: Third-party plugins may involve additional costs).

Install the Base Pixel Code

The Base Pixel should be placed in the header (<head>) of every page on your website to ensure comprehensive tracking across all channels (CTV, Audio, and Display).

Option 1: Native WordPress (No Plugin)

  1. In your Dashboard, go to Appearance → Customize (or your specific Theme Settings).
  2. Look for a section labeled Header/Footer Scripts, Custom Code, or Advanced.
  3. Paste the Base Pixel Snippet (below, remember to replace XXXXX with a unique GTID) into the box designated for the Header.
  4. Click Publish.

Option B: Using the WPCode Plugin

  1. Log in to your WordPress Admin Dashboard.
  2. Go to Plugins → Add New and search for WPCode. Install and Activate.
  3. Navigate to Code Snippets → Header & Footer.
  4. Paste the base pixel code snippet below into the Header section.
  5. Click Save Changes.
Group 12386.png

Base Pixel

 <script>
 window.GTPX_DEBUG = false; 
  (function(g, r, o, u, n, d, t) {
    g[n] = g[n] || function() {
      (g[n].q = g[n].q || []).push(arguments);
    };
    g[n].l = 1 * new Date();
    t = r.createElement(o); t.async = 1; t.src = u;
    r.getElementsByTagName('head')[0].appendChild(t);
  })(window, document, 'script', 'https://analytics.groundtruth-data.com/pixel.v2.js', 'gtpx');
  // Initialize with your unique identifier
  gtpx('init', {
    gtid: 'XXXXX' 
  });
  // Explicitly track pageview
  gtpx('pageview');
</script>

IMPORTANT ACTION: Replace XXXXX with the unique GTID provided by your GroundTruth representative.


Setting Up Custom Events

Optional: To track specific actions like purchases or sign-ups, you must add a supplemental "signal" line of code only to the specific action pages (e.g., a "Thank You" or confirmation page).

Option 1: Native Word Press (Use Custom HTML Block)

If you use the WordPress Block Editor or Elementor, you do not need a plugin to track specific pages.

  1. Edit the specific page where the conversion occurs (e.g., the Thank You page).
  2. Add a Custom HTML block to the page.
  3. Paste the relevant Custom Event snippet (Signup, Cart, or Purchase) into the block.
  4. Update or Publish the page.

Option 2: Using the WPCode Plugin with Conditional Logic

If you prefer to keep all code in one dashboard:

  1. In WPCode, go to Code Snippets → Add Snippet → Add Your Custom Code.
  2. Paste your Custom Event code and set the Location to Header.
  3. Scroll to Smart Conditional Logic and turn it on.
  4. Set the logic to: "Show" this snippet if Page URL is [Your Confirmation Page URL].
  5. Save and Activate the snippet.

Custom Event Snippets

Note: Do not place these snippets in the global header. They should only fire on the page where the action is completed.

Cart

Triggered when a product is added to cart (e.g., gtpx('cart',{amount:49.99});). Remember to replace XXXXX with a numerical value.

gtpx('cart',{amount: XXXXX});

Purchase 

Triggered when a purchase is completed, like on a "thank you" page (e.g., gtpx(‘purchase’,{amount:139.00});). Remember to replace XXXXX with a numerical value.

gtpx('purchase',{amount: XXXXX});

Signup

Triggered when a signup is completed, like when a form fill is completed. Advertiser must decide when a single conversion should be fired.

gtpx('signup';);

Pixel Validation

Once your code is saved in WordPress, follow these steps to [Validate Pixel Installation] using the browser console or a pixel helper.


Frequently Asked Questions

  1. How do I generate the pixel? The base pixel can be found above, which you can copy but remember that you need a unique identifier (GTID) to replace the XXXXX before implementing it onto your website. Reach out to a representative to receive your GTID. 
  2. Do I need to generate a new pixel for every campaign? Generally, no. As long as you are using the same Ads Manager account to drive traffic to the same website, you can reuse your GTID. If the account or the website changes, a new GTID is required.
  3. Where does the pixel need to be placed? On every page of the website to ensure it captures a comprehensive view of the user journey.
  4. Where do I place custom event code? Place custom code only on the specific page that confirms the action (e.g., the post-submission confirmation page). Do not place custom event code in the global header.
  5. What if my site uses a 3rd-party checkout platform? If your site redirects to a different domain, the tracking data may be lost during the redirect. We suggest directing your ad traffic directly to the final conversion domain to ensure accurate reporting.

 

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

Comments

0 comments

Please sign in to leave a comment.