Skip to docs navigation
On this page

Add SourceTrack to WordPress

Add one snippet to your WordPress site with a header plugin or your theme. SourceTrack then records visits to your site's pages.

See which channels and campaigns bring your WordPress visitors and leads.

You need: a SourceTrack account, and admin access to your WordPress site to add a plugin or edit your theme.

Add the snippet with a plugin

This is the easiest way, and your change survives theme updates.

  1. In SourceTrack, open Setup & Health and copy your snippet from Install the script. It already includes your site key. It looks like this:
    HTML
    <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
  2. In WordPress, go to Plugins → Add New and search for WPCode, or any "Insert Headers and Footers" plugin.
  3. Install and activate the plugin.
  4. Open the plugin's settings and paste the snippet into the Header section.
  5. Click Save Changes.

Or add the snippet to your theme

  1. In your theme editor or file manager, open wp-content/themes/your-active-theme/header.php.
  2. Paste the same snippet right before the closing </head> tag.
  3. Save the file.
WarningTheme updates overwrite changes to theme files. Use a child theme or the plugin option above to keep your change.

Check that it worked

  1. Open your WordPress site in a new browser window and visit a page.
  2. In SourceTrack, open Setup & Health. Under Install the script, click Verify installation.
  3. You should see First event received. If you do not, see the problems below.

To watch visits arrive, open Check tracking coverage on the same page and click Show Feed under Live Events Feed.

If it did not work

  • Nothing shows up: If you use a caching plugin, clear its cache. Otherwise visitors keep seeing the old page without the snippet.
  • A speed plugin blocks it: If a plugin combines or delays scripts, add tracker.min.js to its exclude list.
  • Still nothing: See Troubleshooting.

The SourceTrack WordPress Plugin

Instead of pasting the snippet, you can use the SourceTrack WordPress plugin. It is not listed in the WordPress.org plugin directory and has no public download: it is available on request.Contact us to get it.

  • Adds the tracking script to your pages with your site key, so you need no header plugin or theme edit.
  • Records form leads from Gravity Forms, WPForms, Contact Form 7, Elementor Pro Forms, Ninja Forms, Fluent Forms and Formidable Forms, and WooCommerce orders with their revenue.
  • Hides private fields. A form's email and phone fields, and any password, card or token field, are sent as [redacted]. The setting "Strip sensitive form field values" hides every other form value too.
  • Respects privacy signals. The tracker does not run when the visitor's browser sends Global Privacy Control or Do Not Track. A form lead from such a visitor is still recorded, and SourceTrack sends it to no ad platform.
  • Optional consent settings, off by default: wait for the visitor's consent before tracking (with the WP Consent API and a consent plugin that works with it), and follow consent signals from Google Consent Mode, OneTrust and IAB TCF.

Form leads to ad platforms

SourceTrack can pass a form lead on to Meta and the other ad platforms you connected only when the lead arrives with a Form leads token. With a token, the email address and a phone number that includes its country code are sent only as hashed values, and no other form value is sent. Without a token, form leads are recorded for analytics only. Contact us to set up a token.

Next step

Count the actions that matter, like contact form submits or buy clicks, with the Browser Conversions guide.

Still stuck?

Email support@sourcetrack.ai with your site and what you have tried.

Start 28-day free trial
  • Google Ads
  • Meta
  • LinkedIn
  • Microsoft Ads
  • TikTok
  • Stripe
  • Shopify
  • HubSpot
  • GA4
  • Search Console
  • WooCommerce
  • Webflow
  • WordPress
  • Typeform
  • Calendly
  • Intercom
  • Zapier
Works with