← Back to Docs

WordPress Setup Recipe

Integrate the tracking pixel into your WordPress site to capture visitors site-wide.

Who This Is For

This guide is for bloggers, businesses, and creators running WordPress sites who want to establish attribution and track visitor campaigns site-wide.

Key Terms Defined:

  • WP Admin — the backend dashboard where you manage plugins, write pages, and configure your site settings.
  • Theme header (header.php) — the PHP template file that defines the top section of your site, including code placed inside the HTML <head> tags.
  • Caching — storing static versions of your pages to speed up load times. When you edit code, you must clear the cache to show updates.

What You Will Set Up

You will install our pixel code either via a header injection plugin (recommended) or manually inside your active theme's template.

Steps: WordPress Integration

Option 1: Using a Plugin (Recommended)

  1. Log in to your WordPress Admin dashboard.
  2. Go to Plugins → Add New and search for WPCode (or any "Insert Headers and Footers" plugin).
  3. Install and activate the plugin.
  4. Navigate to the plugin settings and paste this code snippet in the Header section:
    <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
  5. Click Save Changes.

Option 2: Direct Theme Edit

  1. Log in to your file manager or theme editor and open wp-content/themes/your-active-theme/header.php.
  2. Paste the script directly before the closing </head> tag:
    <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
  3. Save the file.
Warning: Direct modifications to theme files will be overwritten when the theme updates. We strongly recommend using child themes or Option 1 (WPCode plugin).

How to Verify It Worked

  1. Visit your WordPress website.
  2. Open Developer Tools (right-click → Inspect), click Network, and filter by track.
  3. Refresh the page. Verify a call to POST /api/track completes successfully.
  4. Confirm your browser visits appear in the SourceTrack dashboard Event Debugger.

Common Mistakes

  • Active Cache Blocker: If you use cache plugins (e.g. WP Rocket, W3 Total Cache, Autoptimize), you must clear your site cache after saving changes. Otherwise, visitors will continue loading the old HTML page without the script.
  • Minification Exclusions: If your caching plugin bundles JavaScript, it may break script loading. Exclude tracker.min.js from minification / defer lists if errors occur in your browser console.

Next Step

Setup is complete! You can now track custom conversion goals (like contact form submits or checkout buy clicks) by reviewing theBrowser Conversions guide.