How Referral Tracking and Attribution Work

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 a referral lasts, and the exact order of precedence when a link, a coupon and a checkout code point at different affiliates. Part of the Affiliate and Referral for WooCommerce documentation.

What happens when a link is clicked

↑ Back to top

When a visitor opens a referral link, the click is counted against that link and the visitor’s browser receives a referral cookie naming the affiliate. While the cookie is present, the pages they open are logged as visits, except the cart and checkout. You can see both per affiliate on the Affiliates screen: the Total Visitors card counts the clicks, and the Traffic tab lists the visits. That makes it your first stop when someone asks whether their link “worked”; see Troubleshooting: Referrals Not Tracking.

The click is recorded by a small script in the visitor’s browser. Disabled JavaScript, an aggressive content blocker, or an optimization plugin that delays or removes scripts can stop a click from registering, and nothing else records it. Factor that into how you read affiliate traffic numbers.

How long the credit lasts

↑ Back to top

Go to: WooCommerce > Affiliate & Referral > Advanced Features > General and enter a number of days in Cookie Expiration. Left empty or set to 0, a referral lasts 30 days.

The Cookie Expiration field under Advanced Features setting how many days a referral lasts
The referral window in days

A referral can end earlier. The cookie is cleared when the customer reaches the order confirmation page, so one referral credits one order unless lifetime commission keeps the customer with the affiliate; see How to Set Up Lifetime Commissions for Affiliates. A click on a different affiliate’s link replaces the cookie, so among links the latest click wins.

Who wins when signals disagree

↑ Back to top

When an order is placed, the program looks for an affiliate in a fixed order and stops at the first match:

  1. The customer’s lifetime affiliate. With lifetime commission on, a signed-in customer who is tied to an affiliate credits that affiliate, whatever they clicked or entered.
  2. An affiliate coupon on the order. The coupon’s owner is credited, even if the customer clicked another affiliate’s link before or after applying it. The owner must be an active affiliate. See How to Track Affiliate Sales with Coupon Codes.
  3. The referral link cookie. The affiliate from the latest link click, while the cookie lasts.
  4. A referral code typed at checkout. Used only when none of the above applies.

With none of these, the order pays no commission. Because the decision is made from the finished order, the order in which the customer clicked and applied a coupon does not change the result. Guest checkouts are credited by coupons, links and codes like anyone else; only the lifetime pairing needs a signed-in customer.

The checkout code field

↑ Back to top

Affiliates can also be credited by a code the customer types at checkout — useful when the click happened on another device, or the referral has expired. Go to: WooCommerce > Affiliate & Referral > Bonuses > Bonus settings and turn on Enable checkout referral field. The checkout then gains an optional Affiliate Referral Code field.

The Enable checkout referral field switch under Bonuses > Bonus settings
Enabling the checkout field
The block checkout with the optional Affiliate Referral Code field for an affiliate's code
The code field at checkout

The field appears on the block checkout, the default in current WooCommerce. The classic shortcode checkout does not have it — on a classic checkout, rely on links and coupons instead.

FAQ

↑ Back to top

Is attribution first-click or last-click?

↑ Back to top

Last-click among referral links: each click on another affiliate’s link replaces the cookie. An affiliate coupon on the order outranks any link, and lifetime commission is the exception to both — the first affiliate to refer a signed-in customer keeps them.

Does tracking work for guests who never sign in?

↑ Back to top

Yes. Links, coupons and the checkout code all credit guest orders. Only the lifetime pairing needs a signed-in customer, because it is stored against their account.

Can an affiliate be credited without any click at all?

↑ Back to top

Yes, two ways: their affiliate coupon, or their referral code typed into the checkout field. Both work with no earlier visit. More questions are answered in the Affiliate and Referral Program: FAQ.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.