your-marketing-site.com is invisible to your-app.com, even though both are yours — so a visitor who lands on one and converts on the other arrives at checkout with no attribution at all.
Cross-domain tracking closes that gap. You tell Referly which domains belong to you, and the tracker hands attribution across whenever a visitor moves between them.
Subdomains already work
Before configuring anything, check whether you actually need this. Referly writes its cookies on your registrable domain with a leading dot —.your-domain.com, not www.your-domain.com — which it works out from the public suffix list. Every subdomain therefore reads the same cookie automatically:
Approve your domains
In your dashboard go to Settings → Program details → Cross-domain tracking and add each domain under Approved Domains. Enter the bare domain — no protocol, nowww, no path. Referly normalises what you type (stripping https://, a leading www., and anything after the first slash) and rejects anything that isn’t a valid domain, but entering it cleanly avoids surprises:
example.com also approves shop.example.com and blog.example.com. Matching is an exact hostname match or a suffix match on a dot boundary, so example.com never accidentally matches notexample.com.
Install the snippet on every domain
This is the step people miss. Each domain in the group needs the tracking snippet installed, with the same program ID. The handoff is a conversation between two copies of the tracker — if the receiving domain has no tracker, the parameters arrive and nothing reads them. Both domains must also be served over HTTPS, since attribution is stored inSecure cookies.
How the handoff works
Nothing about your links changes. You don’t rewrite URLs, add parameters, or call an API.On the sending domain
Once attribution is resolved for the current visitor, the tracker attaches a click listener to the document in the capture phase. When a click happens it walks up from the clicked element to the nearest anchor and checks its hostname. If that hostname is on your approved list and its registrable domain differs from the current page’s, the tracker rewrites the link’shref at that instant, appending two parameters:
action, and if it points at an approved domain other than the current one, appends the two parameters to it.
On the receiving domain
The tracker checks for_plg_ref before anything else it does. When it finds one, it:
- Adopts the referral code and click ID as this visitor’s attribution.
- Writes them into the receiving domain’s own storage, so the handoff only has to happen once.
- Removes both parameters from the address bar with
history.replaceState, preserving the path, the hash, and every other query parameter.
A handoff restores an existing referral rather than creating a new one, so no additional click is recorded and the affiliate’s click count doesn’t inflate when a visitor moves between your domains.
Testing it
1
Land on the first domain with a referral
Open
https://domain-a.com/?ref=TESTCODE in a fresh browser profile and confirm window.affiliateRef returns the code.2
Inspect a link before clicking
Hover a link pointing at your second domain. Its
href is still clean — decoration happens on click, not before.3
Click through
Watch the address bar on arrival. You may briefly see
_plg_ref and _plg_cid before they’re stripped.4
Confirm on the second domain
Run
window.affiliateRef and window.affiliateId there. Both should match what you saw on the first domain. Check Application → Cookies for the two program-scoped entries.5
Reload with a clean URL
Navigate around the second domain with no parameters. Attribution should persist — the handoff has been written into local storage.
Limitations
Only real links and form actions are decorated
Only real links and form actions are decorated
Navigation driven from JavaScript —
window.open(...), window.location.href = ..., a router push — never touches an anchor’s href, so nothing is decorated. If you navigate cross-domain programmatically, append _plg_ref and _plg_cid yourself from window.getPushLapAffiliateInfo().Middle-click, right-click, and copied links
Middle-click, right-click, and copied links
Decoration happens when the click event fires. Opening a link in a new tab with the middle mouse button, or copying the link address from the context menu, can bypass it and yield the undecorated URL.
Clicks before the tracker has resolved
Clicks before the tracker has resolved
The listeners are attached only after attribution has been worked out, which takes a network round trip on a first visit. A click in the first moments of a page load can land undecorated. Rare in practice, but real on slow connections.
Iframes and embedded checkouts
Iframes and embedded checkouts
A tracker in the parent page cannot reach inside a cross-origin iframe to decorate links there. Embedded checkout widgets need the platform’s own integration instead.
No attribution means no decoration
No attribution means no decoration
Links are left alone for visitors who didn’t arrive from an affiliate link. That’s deliberate — ordinary visitors never see tracking parameters on your URLs.
Redirects that drop query parameters
Redirects that drop query parameters
If the receiving domain redirects the landing URL through something that strips unknown parameters, the handoff is lost before the tracker sees it. Preserve the query string across redirects on your entry points.
Same-domain links are never touched
Same-domain links are never touched
Links between subdomains of one registrable domain aren’t decorated, because the cookie is already shared. Nothing to fix.
Removing a domain
Delete a domain from Approved Domains and decoration to it stops on the next page load. Attribution already written into that domain’s storage stays there until its window expires — removal is not retroactive.Related
Cookies and storage
Why subdomains share a cookie and separate domains don’t.
URL parameters
Where _plg_ref and _plg_cid sit among the other parameters.
Install the snippet
Every domain in the group needs the same snippet.
Attribution and the cookie window
What happens to attribution after the handoff.
JavaScript API
Read attribution yourself for programmatic navigation.
Debug mode
Log decoration and restore on both sides.