Overview
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.
Managing Code in WordPress
There are two primary ways to manage custom code snippets in WordPress:
- Native (No Plugin): Many modern themes (e.g., Astra, Divi, Genesis) feature a built-in "Header/Footer Scripts" or "Custom Code" section inside the Theme Customizer.
-
Plugin-Based: Using a plugin like WPCode (Insert Headers and Footers) allows you to manage code snippets from a central dashboard without modifying your theme’s
header.phpfile. (Note: Third-party plugins may involve additional costs).
Part 1: 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 media channels (CTV, Audio, and Display).
Option 1: Native WordPress (No Plugin)
- In your WordPress Admin Dashboard, go to Appearance > Customize (or your specific Theme Settings).
- Look for a section labeled Header/Footer Scripts, Custom Code, or Advanced.
- Copy your auto-generated Base Pixel code snippet from Ads Manager (Step 6: Measurement) and paste it into the designated Header box.
- Click Publish.
Option 2: Using the WPCode Plugin
- Log in to your WordPress Admin Dashboard.
- Go to Plugins > Add New, search for WPCode, then install and activate it.
- Navigate to Code Snippets > Header & Footer from the left sidebar.
- Copy your auto-generated Base Pixel code snippet from Ads Manager (Step 6: Measurement) and paste it into the Header section.
- Click Save Changes.
Part 2: Setting Up Custom Events (Optional)
To track specific bottom-funnel actions like purchases or sign-ups, add a supplemental "signal" line of code exclusively to your post-action confirmation pages (e.g., a "Thank You" or order summary page).
Option 1: Native WordPress (Use Custom HTML Block)
If you use the WordPress Block Editor (Gutenberg) or Elementor, you can place page-specific event snippets without a plugin:
- Edit the specific page where the conversion occurs (e.g., the Thank You page).
- Add a Custom HTML block to the page layout.
- Paste the relevant Custom Event snippet (Conversion, Cart, or Purchase) into the block.
- Click Update or Publish.
Option 2: Using the WPCode Plugin with Conditional Logic
If you prefer managing all site scripts from a centralized dashboard:
- In WPCode, go to Code Snippets > Add Snippet > Add Your Custom Code.
- Paste your Custom Event snippet into the code box and set the Code Type to HTML Snippet (or wrap in
<script>tags). - Set the Location to Header.
- Scroll down to Smart Conditional Logic and toggle it ON.
- Set the rule to: Show this snippet if Page URL is
[Your Confirmation Page URL]. - Save and activate the snippet.
Custom Event Snippets Reference
📝 Conversion: Triggered when a specific action (e.g., form fill or registration) is completed. Replace my_goal_name with a custom descriptor.
gtpx('conversion',{label:'my_goal_name'});🛍️ Cart: Triggered when a product is added to a cart. Replace XXXXX with a numerical price value.
gtpx('cart',{amount: XXXXX});💳 Purchase: Triggered when a purchase is completed. Replace XXXXX with the final checkout total.
gtpx('purchase',{amount: XXXXX});Part 3: Validating Your Installation
Once your code is saved in WordPress, follow our [Validate Pixel Installation] guide to verify event firing using browser developer tools or a pixel extension.
Frequently Asked Questions
-
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. - 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.
-
Where does the pixel need to be placed? Place the Base Pixel in the global header (
<head>) of every page on your site to capture full post-click user journeys. - Where do I place custom event code? Place custom snippets (e.g., purchase or form fill confirmations) only on the specific post-action confirmation page. Do not place custom event code in the global header.
- What if my site uses a 3rd-party checkout platform? If your site redirects users to an external checkout domain, tracking signals may be lost. We suggest directing ad traffic directly to landing pages and checkout flows hosted on your primary domain.
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.
Comments
Please sign in to leave a comment.