Tracking & Attribution
First-party cookie tracking, direct link matching, standalone conversion pages, and configurable attribution models for affiliate referrals.
Referral Tracking
Royal Affiliate Pro uses cookie-based tracking to attribute sales to the correct affiliate.
How It Works
- Visitor clicks an affiliate link:
yoursite.com/?ref=affiliatecode - The plugin sets a
rafp_refcookie containing the affiliate ID, campaign ID, and timestamp - The cookie persists for a configurable duration (default: 30 days)
- When the visitor makes a purchase, the cookie is read and a referral is created
From 2.6.26 the cookie is signed. A cookie that has been edited, for example to name a different affiliate or campaign, is ignored and the sale is not credited from it. Cookies set before you updated keep working until they expire.
URL Parameters
| Parameter | Purpose |
|---|---|
?ref=code |
Main referral parameter |
?affiliate=code |
Alternative referral parameter |
?campaign=slug |
Campaign tracking |
?creative=id |
Creative tracking |
Tracking Settings
| Setting | Default | Description |
|---|---|---|
| Cookie Duration | 30 days | How long the tracking cookie persists |
| Referral Code Format | Username | Username-based or random code |
| Link Format | Pretty | Query string (?ref=code), or cloaked links under /recommend/ |
| Cross-Subdomain | Off | Share cookies across subdomains |
| Clear After Conversion | Off | Remove cookie after first purchase |
| Cookie Consent | Track referrals right away | Wait for marketing consent before tracking (see Cookie consent) |
Attribution Models
Choose how Royal Affiliate Pro attributes sales when a customer clicks multiple affiliate links.
Available Models
- First Click - The first affiliate to send the customer gets credit for all purchases. The original cookie is never overwritten.
- Last Click (Default) - The most recent affiliate click overwrites the cookie. The last affiliate to send the customer gets credit.
Excluded Pages
Block referral tracking on specific URLs. Supports wildcards and regex patterns to exclude checkout pages, admin areas, or any URLs where tracking should not apply.
Forced Landing Pages
Designate specific pages as forced landing pages. When an affiliate link lands on these pages, the cookie expiration is refreshed, extending the tracking window.
Who gets the order
The affiliate is saved on the order at checkout. Whoever marks the order paid later (you, a payment webhook or a scheduled task) does not change who gets the commission.
Coupon or link
When a buyer came through one affiliate's link and uses another affiliate's coupon, Settings → General → Coupon or Link decides who gets the sale. The default is The coupon wins. Choose The link wins to credit the affiliate whose link the buyer followed. An inactive affiliate's coupon never earns.
Cookie consent
If your site asks visitors for cookie consent, Royal Affiliate Pro can wait for it. Go to Settings → General → Cookie Consent and choose Wait for marketing consent.
How it works
- A visitor arrives through an affiliate link
- Until they accept marketing cookies, no visit is recorded and no referral cookie is set
- As soon as they accept, the visit is recorded on the same page, without a reload
Supported consent banners
- CookieYes (the Advertisement category)
- Complianz (the Marketing category)
- Iubenda (the Marketing purpose)
- Any banner that uses the WP Consent API in opt-in mode
Developers can decide consent themselves with the rafp_has_tracking_consent filter.
Visits on your other sites
If your sales pages live on another site (for example a marketing site on its own domain), add that site under Settings → General → Script Sites and put the tracking script from that screen on every page of it.
What the script does
- When a visitor lands on that site through an affiliate link, the visit is counted right away, even if they never reach the store
- It keeps the referral code and adds it to every link to the store, so the store sets the referral cookie and reuses the same visit
- With Cookie Consent on, it stores and reports nothing until the visitor accepts
- Safari keeps what a script saves for at most 7 days, so on Safari a saved referral code from a script site can expire sooner than your cookie duration
Sites with a Content Security Policy
If the other site sends a Content-Security-Policy header, allow your store's address in both script-src (to load the script) and connect-src (to count the visit):
script-src 'self' https://store.example.comconnect-src 'self' https://store.example.com
Standalone Conversions
Track affiliate referrals without WooCommerce by placing the [rafp_conversion] shortcode on any thank-you or confirmation page.
This feature requires an Agency license.
How It Works
Place the shortcode on a confirmation page that visitors reach after completing an action (purchase, signup, form submission). The shortcode reads the affiliate tracking cookie and creates a referral.
Works With
- Stripe Checkout
- PayPal
- ThriveCart
- Gumroad
- Any external checkout that redirects back to your site
Amount and reference
Set the sale amount and a unique reference in the shortcode:
[rafp_conversion amount="99.99" reference="INV-001"]
Values in the page address (?amount=, ?reference=) are ignored by default, because anyone can change an address. Developers who sign or check those values themselves can allow them with the rafp_conversion_query_values filter. Conversions are recorded as pending, and the page is never served from a page cache.
Direct Link Tracking
Attribute visits without the ?ref= parameter by matching the HTTP Referer header against affiliate-registered domains.
How It Works
- Affiliates can suggest their website domains in their dashboard under Profile → Promotion Domains
- You list the domains that count on the affiliate's screen under Approved direct-link domains (one per line); a domain you add there counts even if the affiliate never suggested it
- When a visitor arrives at your site, Royal Affiliate checks the Referer header
- If the referer domain is on that list, the tracking cookie is set automatically, with no
?ref=parameter needed
Domains that never count
- Your own site and your allowed destination and script sites (and their subdomains)
- Large platforms such as Google, Facebook, X, LinkedIn, Reddit, YouTube and GitHub
- A domain that two affiliates both have
Domains affiliates had already added when you updated to 2.6.23 stay approved. Developers can extend the list of domains that never count with the rafp_direct_link_protected_domains filter.
Limitations
- The HTTP Referer header is not always sent (HTTPS → HTTP, privacy settings, some browsers)
- Not a replacement for cookie-based tracking — use as a supplementary attribution method
- Domain matches are cached with a 1-hour transient for performance