Skip to main content
Every time the Referly tracking script resolves a referral on one of your pages, it records a click. A click is the atomic unit of tracking in Referly: it holds the affiliate who sent the visitor, the link they used, the campaign parameters on the URL, and a snapshot of the visitor’s browser and location at that moment. Everything downstream — attribution, the analytics breakdowns, the clickId you pass to server-side endpoints — hangs off that record. This page is the reference for what a click contains, when one is created, and how it later gets tied to a conversion.

When a click is recorded

The tracking script decides this on every page load, after it has read your program’s urlModifier (the referral parameter name, ref by default). There are three outcomes: So a click is written only when a referral parameter is actually present in the URL. Ordinary navigation around your site after the first landing does not create additional clicks. See attribution for how the stored referral is chosen when several are in play.
Only referral codes that resolve to a real affiliate link in your program produce a click. If the code does not match any link, the request is rejected and nothing is stored.

The click ID

Each click gets an incrementing numeric ID. As soon as the click is written, the script:
  • sets window.affiliateId to the click ID as a string (before the click resolves, this briefly holds the referral code instead),
  • stores it in the PROGRAM_ID_affiliate_referral cookie or localStorage key for the length of your cookie window,
  • fires the affiliate_id_ready event with both values.
That click ID is what you pass back to Referly when you report a sign-up or a sale from your own server. See reporting sales and the JavaScript API reference.

Associations stored on the click

Every click is written against the identifiers that were resolved at the time: Because the link is recorded separately from the affiliate, an affiliate with several links keeps per-link click counts. If a link is later deleted, the click survives with an empty affiliateLinkId rather than disappearing from your totals.

Landing page and URL

The full landing URL is captured, plus two parsed pieces of it so you can group without string surgery:

Campaign and ad click IDs

The five standard UTM parameters are read off the landing URL and stored in their own fields: utmSource, utmMedium, utmCampaign, utmTerm, and utmContent. Alongside them, Referly captures the click identifiers the major ad platforms append to their destination URLs — gclid, gbraid, wbraid, fbclid, msclkid, ttclid, twclid, and liFatId — plus extClickId for affiliate networks that pass their own tracking ID. Each has its own column and its own index, so they are all filterable in analytics. These two families get their own pages: UTMs and ad click IDs and external click IDs.

Referrer

Three fields describe where the visitor came from before landing: referrerType is derived in the browser and is one of:
  • direct — no referrer at all (a typed URL, an app, a stripped referrer).
  • paid — any of the ad platform click IDs above was present on the URL. This wins over every other classification.
  • search — the referrer domain matches a known search engine: Google, Bing, Yahoo, DuckDuckGo, Baidu, Yandex, Ecosia, Ask, AOL, Startpage, Qwant, or Brave.
  • social — the referrer domain matches a known social platform: Facebook, Instagram, X, LinkedIn, Pinterest, TikTok, Reddit, YouTube, Snapchat, WhatsApp, Telegram, Discord, Tumblr, Threads, or Mastodon.
  • email — the referrer domain matches a common mail host or email platform, including Outlook, Yahoo, Gmail, Proton Mail, Zoho, Mailchimp, SendGrid, Constant Contact, HubSpot, Klaviyo, ConvertKit, and Drip.
  • unknown — there was a referrer, but it matched none of the lists.
Matching is a case-insensitive substring test against the hostname, so www.google.co.uk and news.google.com both classify as search.

Device, browser, and operating system

The raw user agent is stored in full, and the script also derives a normalised breakdown from it so you are not parsing user agent strings in your own reporting: Anything the script cannot confidently identify is left empty rather than guessed — a browser that does not match one of the known patterns stores its user agent with no browserName. deviceType is the exception: it falls back to desktop when nothing matches.

Screen, viewport, and language

Useful for spotting whether affiliate traffic is landing on layouts you have not designed for:

IP address and location

These are the only fields the browser does not supply. Referly resolves them server-side, from the request itself, when the click is written. The IP address is read from the first of these request headers that is present: x-forwarded-for (the first address in the list), x-real-ip, cf-connecting-ip, x-vercel-forwarded-for. If none are set, ipAddress is left empty. Location comes from the CDN’s own geolocation headers rather than a lookup service, so it adds no latency to the click: geoCountry is a two-letter ISO country code. City names arrive URL-encoded and are decoded before storage. When neither provider supplies the headers, all three fields are left empty — the click is still recorded.

Unique and repeat clicks

Every click carries a uniqueClick flag. It is true for the first click that established the referral in a given browser, and false for any later click where the visitor arrives on a referral URL for a code that is already stored. Analytics uses this flag directly: the clicks breakdown in your dashboard has an all mode that counts every row and a unique mode that counts only the rows where uniqueClick is true. Both are real click totals for the same period — they differ only in whether repeat arrivals from the same browser are included.
uniqueClick is per browser, not per person. Someone who clicks the same affiliate link on their phone and again on their laptop produces two unique clicks, because the flag is decided from the referral stored in that browser. Clearing cookies has the same effect.

How a click becomes a conversion

A click starts life with no referralId. It gets one when a conversion is reported and carries a click ID with it:
1

You report the conversion

Your integration, snippet, or server call sends the conversion along with the click ID it read from window.affiliateId.
2

Referly looks up the click

The click ID is parsed as a number and the matching click is loaded. A missing or non-numeric ID is skipped silently — the conversion still records, it just will not be joined to a click.
3

The referral is created

A referral is created for the customer, credited to the affiliate and the affiliate link.
4

The click is stamped

The click’s referralId is set to the new referral. From that point the click, the referral, and any sales on it form one chain.
Only the click whose ID was reported gets stamped. Earlier repeat clicks from the same browser stay unattributed, which is what keeps click counts and conversion counts independent of each other. The click ID is also included in postback URL fires, so an affiliate network can reconcile against the same identifier you used.

Where click data comes from

Splitting it by origin is the quickest way to reason about what can go missing: Anything in the first row depends on the tracking script running to completion in the visitor’s browser. A blocked script means no click at all, not a partial one. Debug mode prints exactly what was collected and what came back.

Retention

Clicks are kept for as long as the program exists. There is no expiry job and no rolling window — a click from two years ago is still queryable in analytics. Deletion is by cascade. Removing an affiliate removes their clicks; removing a program removes all of its clicks. Deleting an affiliate link is the exception: the clicks remain and their affiliateLinkId is cleared. Do not confuse this with your cookie window, which defaults to 60 days and is configurable per program. That window controls how long a referral stays attributable in the visitor’s browser, not how long the click record is stored. See cookies and storage.

UTMs and ad click IDs

Every campaign and ad platform parameter Referly reads off the landing URL.

External click IDs

Passing a network’s own tracking ID through Referly and back out again.

Attribution

How Referly decides which affiliate gets credit for a conversion.

Cookies and storage

What the tracking script stores in the browser, and for how long.
Last modified on July 21, 2026