Skip to main content
WordPress runs the site, but it doesn’t take the money. That one fact shapes this whole guide. Tracking affiliate referrals on WordPress comes in two halves. The first half is the same for everyone: put the Referly tracking script on your site so visitors arriving from an affiliate link are recognised. The second half depends entirely on how you sell, because the sale is recorded by whatever handles your checkout, not by WordPress. This article covers the first half in detail, with four different ways to add the script, and then points you at the right setup for the second half.
There’s no WordPress card in Settings, then Integrations in your Referly dashboard. That’s expected. WordPress is where your site lives, so you’ll be using the card that matches your checkout instead: one of the Stripe guides, or Woocommerce. This article tells you which.

What you can and can’t track

Before you start

You’ll need:
  • A live Referly program with at least one affiliate to test with. See setting up your program if you haven’t got that far.
  • An administrator account on your WordPress site.
  • To know how you take payment, because that decides the second half of the setup.

Get your tracking script

Your script is inside Referly with your program’s own identifier already filled in. Open Settings from the left sidebar, select Integrations, and open Instructions on whichever card matches your checkout. Every one of them shows the same tracking script under Step 1. It looks like this, with your own identifier in place of YOUR_PROGRAM_ID:
Copy it now. The next section covers where to put it.

Add the script to WordPress

The script belongs in the head section of every page on your site. Pick one of the four methods below, whichever fits your setup. You only need one.
Don’t paste this into your parent theme’s files. WordPress overwrites theme files when the theme updates, so your tracking would vanish silently at the worst possible moment. Use one of the methods below instead.
This is the part that catches WordPress users out, and it’s worth ten minutes before you go any further. Your script can be perfectly installed and still never run.

Caching plugins

After adding the script, clear your cache. Every caching plugin serves visitors a saved copy of your pages, and until you clear it, they’ll keep getting the old version without your script. In WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache, or whatever you use, find the option to clear or purge all caches and run it. Then check your plugin’s minification and JavaScript optimisation settings. Options named things like “Combine JavaScript”, “Defer JavaScript”, “Delay JavaScript execution”, or “Load JavaScript deferred” can stop the tracking script working properly, usually by making it run too late to catch the visit. If tracking doesn’t work after everything else checks out, add the Referly script to your plugin’s exclusion list, which most of them offer. If you use a consent plugin like Complianz, CookieYes, or Borlabs, check whether it’s set to block scripts until a visitor accepts. If it is, and your visitor declines or ignores the banner, no click is recorded and that affiliate loses the referral. This is a real trade-off rather than a bug, and where you land on it depends on your legal obligations and where your visitors are. Decide deliberately rather than discovering it later.

Cloudflare Rocket Loader

If your site sits behind Cloudflare with Rocket Loader turned on, it changes how scripts load and can break tracking. The fix is to tell Rocket Loader to leave the script alone by adding one attribute, which must come before src:
Cloudflare’s own reference is ignoring JavaScripts in Rocket Loader.

Security and firewall plugins

Some security plugins strip script tags from admin fields as a precaution. If you paste the script, save, and it’s gone when you come back, that’s what happened. Use the plugin method instead, since dedicated code plugins are designed to hold scripts safely.

Choose how your sales get recorded

The tracking script recognises the visitor. Something else has to tell Referly a sale happened. Find your situation below.
Running WooCommerce? Everything above about installing the script still applies, then follow the WooCommerce article for the order side. Don’t set up both WooCommerce and a Stripe payment link setup for the same products, or you’ll record each sale twice.
If you take payment through Stripe in a way that isn’t listed, connecting Stripe to Referly is usually enough on its own. See the Stripe integration.

Track sign-ups and form submissions

If you want affiliates credited for leads and registrations rather than only sales, add this second script. It watches the forms on a page and records the email address when someone submits one. Add it to the page where people sign up or enter their email, near the bottom, before the closing body tag. Using a header-and-footer plugin, that’s the Footer box under Code Snippets, then Header & Footer.
The tracking script has to be on that same page for this to do anything. It picks up the standard WordPress registration form and most popular form plugins, because it looks for the email field rather than expecting a particular form. Two things worth knowing. Visitors who didn’t arrive from an affiliate link are ignored, so your organic sign-ups aren’t affected. And this records the person as a referred customer with no revenue attached, which is what you want when paying per lead.
If you put this in your site-wide Footer box, it applies to every form on the site, including your contact form and comment forms with an email field. Put it only on the pages you want counted if that’s not what you’re after.

Test it end to end

1

Grab a real affiliate link

Open Affiliates in the left sidebar of Referly, pick an affiliate, and copy their referral link.
2

Clear your cache first

Purge your caching plugin, and Cloudflare’s cache too if you use it. Testing against a cached page is the most common way to waste an afternoon here.
3

Open the link in a private window

Use a private or incognito window. Visit the link and let the page finish loading. If a cookie banner appears, accept it, so you’re testing the path most visitors take.
4

Check the click was recorded

In Referly, look at your affiliate’s clicks. A new one should appear within a moment. If it doesn’t, the script isn’t running, so stop here and work through the troubleshooting below before going further.
5

Complete a sign-up or purchase

In the same window, sign up or buy something using details you haven’t used before.
6

Check Referly

Open Customers in the left sidebar. The referral should appear within a minute, credited to the affiliate whose link you used, with the amount if it was a purchase.
When the click appears and the sign-up or sale appears against the right affiliate, both halves are working.
Remove the test referral in Referly so your reports start clean.

Limitations to be aware of

  • WordPress itself never records a sale. It’s the site, not the checkout. Something else always has to report the money.
  • Caching can hide changes for hours. Always clear your cache after any change, and again before testing.
  • Consent banners can cost you referrals. If scripts are blocked until a visitor accepts, declined banners mean uncounted clicks.
  • Theme-based installation doesn’t survive a theme change. Use a plugin if you expect to redesign.
  • Never edit parent theme files. Updates overwrite them and tracking disappears without warning.
  • The form script captures leads, not revenue. Sign-ups arrive with no value attached.
  • The visitor must convert in the browser they clicked in. Clicking on a phone and buying on a laptop won’t match.
  • Ad blockers and strict privacy settings stop the tracking script for a small share of visitors, as with any affiliate tool.

Troubleshooting

Work through this in order. Clear every cache, including your caching plugin and Cloudflare. Confirm the script is still saved where you put it, since some security plugins strip script tags on save. Confirm it’s in the Header box rather than Body or Footer. Then load your site with an affiliate link on the end, in a private window, and check again.
A security or firewall plugin is stripping it. Use a dedicated header-and-footer plugin like WPCode, which is built to store scripts safely, rather than pasting into a general-purpose settings field.
If the script was in your theme’s files or settings, a theme update or theme change removed it. Move it into a header-and-footer plugin so it’s independent of your theme.
This pattern points at JavaScript optimisation. In your caching plugin, look for settings named “Combine JavaScript”, “Defer JavaScript”, “Delay JavaScript execution”, or similar, and add the Referly script to the exclusion list. If you use Cloudflare, check whether Rocket Loader is on and add the data-cfasync="false" attribute shown above.
The first half works and the second half isn’t set up. Find how you sell in the table above and follow the setup it points to. The tracking script on its own never records a sale.
Check that both scripts are on the sign-up page: the tracking script in the header, and the form script in the footer. If your form plugin submits without a normal form submission, this script won’t catch it, and the universal setup is the better route.
You have two setups running for the same products, most often WooCommerce alongside a Stripe payment link setup. Pick one and remove the other.
Still stuck? Book an integration call and we’ll go through your setup with you.

WooCommerce

Record orders from a WooCommerce store.

Stripe payment links

The most common way to sell from a WordPress page.

Universal integration

Track a checkout that isn’t listed.

All integrations

See every platform Referly connects to.
Last modified on July 21, 2026