Referral tracking decides which affiliate is credited for an order, and for how long after a click that credit lasts. This page explains how Affiliate and Referral Program for WooCommerce records clicks, how long the referral window stays open, and the exact order of precedence when several signals point at different affiliates. Part of the plugin documentation.
What happens when a link is clicked
↑ Back to topOpening a referral link does three things: the click is counted against that link, the visitor’s browser is given a referral cookie naming the affiliate, and the visit is logged — page, device, platform, browser and IP address. You can see that log per affiliate on the Traffic tab of their detail view on the Affiliates screen, which makes it your first stop when someone asks whether their link “worked”; see Troubleshooting: Referrals Not Tracking.

Tracking runs in the visitor’s browser with JavaScript. A browser with scripts disabled, an aggressive content blocker, or an optimization plugin that strips scripts can prevent the click from registering — there is no server-side fallback. Factor that into how you read affiliate traffic numbers.
How long the credit lasts
↑ Back to topThe referral cookie’s lifetime is yours to set. Go to: WooCommerce > Affiliate & Referral > Advanced Features > General and enter a number of days in Cookie Expiration. Left empty, the program uses 30 days — and note that entering 0 does not create a browser-session cookie as the on-screen hint suggests; a zero gets the same 30-day default.

The window can end early. The cookie is cleared once an order is placed and credited, and it is replaced whenever the visitor clicks a different affiliate’s link or applies a different affiliate’s coupon — the newest signal always wins.
Who wins when signals disagree
↑ Back to topAt checkout the program looks for an affiliate in a fixed order and stops at the first match:
- Lifetime mapping. If lifetime commission is on and the logged-in customer is already tied to an affiliate, that affiliate is credited — regardless of any later clicks or coupons. See How to Set Up Lifetime Commissions for Affiliates.
- The referral cookie. The affiliate from the most recent link click — or from the most recently applied affiliate coupon, which rewrites the same cookie. See How to Track Affiliate Sales with Coupon Codes.
- A code entered at checkout. Used only when no cookie affiliate was found.
- Nobody. With none of the above, the order pays no commission.
Put simply: cookie attribution is last-click, and a lifetime mapping outranks everything. Guest checkouts are credited through the cookie like anyone else — only the lifetime mapping requires the customer to be logged in.
The checkout code field
↑ Back to topAffiliates can also be credited by a code the customer types at checkout — useful when the click happened on another device, or the cookie is long gone. Turn on Enable checkout referral field at WooCommerce > Affiliate & Referral > Advanced Features > Bonus, and the checkout gains an optional Affiliate Referral Code field.


The field appears on the block checkout (the default in current WooCommerce). The classic shortcode checkout does not have it — on classic checkout, rely on links and coupon codes instead.
FAQ
↑ Back to topIs attribution first-click or last-click?
↑ Back to topLast-click for ordinary tracking — each valid click replaces the cookie. Lifetime commission is the exception: the first affiliate to refer the logged-in customer keeps them until you override the mapping.
Does tracking work for guests who never log in?
↑ Back to topYes. The cookie and the checkout code both credit guest orders. Only the lifetime mapping needs a logged-in customer, because it is stored against their account.
Can an affiliate be credited without any click at all?
↑ Back to topYes, two ways: a coupon code assigned to them, or their code typed into the checkout field. Both work with no prior visit. More questions are answered in the Affiliate and Referral Program: FAQ.