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 ofYOUR_PROGRAM_ID:
Add the script to WordPress
The script belongs in thehead section of every page on your site. Pick one of the four methods below, whichever fits your setup. You only need one.
- Plugin (recommended)
- Your theme's own setting
- Child theme (advanced)
- Google Tag Manager
Install the plugin
Open the header and footer settings
Paste into the Header box
Save
Check that caching and consent plugins aren’t blocking it
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.Cookie and consent banners
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 beforesrc:
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.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 closingbody tag. Using a header-and-footer plugin, that’s the Footer box under Code Snippets, then Header & Footer.
Test it end to end
Grab a real affiliate link
Clear your cache first
Open the link in a private window
Check the click was recorded
Complete a sign-up or purchase
Check Referly
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
No clicks are recorded at all
No clicks are recorded at all
The script disappears after I save it
The script disappears after I save it
It worked, then stopped after a site update
It worked, then stopped after a site update
Tracking is unreliable, working sometimes but not always
Tracking is unreliable, working sometimes but not always
data-cfasync="false" attribute shown above.Clicks are recorded but sales never are
Clicks are recorded but sales never are
Sign-ups aren't being captured
Sign-ups aren't being captured
Every sale is recorded twice
Every sale is recorded twice
A referral wasn't credited even though the customer used an affiliate link
A referral wasn't credited even though the customer used an affiliate link