How long a click counts
How long each route can carry a creator's click to the sale, from the discount code to your own server, and the click window over all of them.
Two things decide whether a purchase is credited through a creator's tracked link. The first is the business's click window: how many days after a click a purchase still counts, 30 unless it is changed in Settings, from 1 to 365. The report states that number. The second is whether the route that reports the purchase still has the click when the purchase is made. A purchase is credited through the link only when both hold. The discount code needs neither.
How long a route can carry the click depends on what you can build: nothing, a script you paste, or your own server.
| Route | What it needs | How long it carries a click |
|---|---|---|
| Discount code | no engineering | No time limit and no click needed. Credited where the order reaches us with its codes: a connected Shopify store, or your own server. |
| Shopify order notification | no engineering | The click when the landing page Shopify stores with the order carries it. Shopify doesn't document which visit that page is from. |
| Browser pixel | paste a script | 30 days at most, whatever the click window. Safari keeps it 7. |
| Shopify custom pixel | paste a script | No expiry set: until the browser removes it. Safari can remove it after 7 days. |
| Server API | your own server | As long as your server keeps the click id. The click window still decides whether it credits. |
No engineering#
The discount code#
A code has no window. It is the creator's alone, so a checkout that uses it is theirs whenever it happens and wherever the shopper heard it: a billboard, a podcast read, or a video description from three years ago. No click is needed and nothing is stored on the shopper's device.
It is credited only where the order reaches us together with its codes: from a connected Shopify store, or reported from your own server. The browser pixel never sees codes, so on a store that uses the pixel alone, a code rewards the shopper but credits nothing.
Shopify's order notification#
A connected Shopify store sends us every order with the landing page Shopify stores with it. When that address carries the click id the tracked link added, the order is credited to the click. Shopify's documentation shows the field but doesn't say which of the shopper's visits it comes from, so we don't say how long it carries a click. The custom pixel below keeps the click itself, from the visit that came through the link.
Paste a script#
The browser pixel#
For stores that aren't on Shopify. The pixel keeps the click in a first-party cookie, proof_ref, set to expire 30 days after the click and not extended by later visits. That is 30 days whatever the business's click window, because the pixel is one script for every site and doesn't know the setting. Through the pixel, a click counts for the shorter of the two.
Browsers can delete the cookie sooner, and we don't control that. Safari caps a cookie set by a script at 7 days (WebKit, 2019), and at 24 hours when the visitor arrives from a site Safari classes as a tracker, on an address with a query string (WebKit). Cleared cookies and private windows end it too.
The Shopify custom pixel#
Pasted in Shopify → Settings → Customer events, and run only when the shopper has allowed analytics. It keeps the click in your store's browser storage, yonto_ref, with no expiry set, so a purchase on a later visit is still credited for as long as the click window allows. A later click on a tracked link replaces it.
It lasts until the browser removes it: when the shopper clears their data for your store, or sooner where the browser deletes stored data on its own. Safari deletes a site's script-written storage after 7 days of Safari use without the shopper tapping, clicking or typing on that site (WebKit, 2020).
Your own server#
The server API carries whatever click id your server sends, so a click lasts as long as you keep its id. Capture it when the visitor lands, store it against the customer in your own database, and report the sale whenever it happens. Once it is in your database it no longer depends on the shopper's browser.
The API accepts a click id of any age, but the click window decides whether it still credits the sale. A click older than the window is refused with a 422, and nothing is recorded. A sale three years after its click is past any window, which is 365 days at most. A sale sent with no click id is recorded as your own statement that it is the campaign's, and the report counts it as reported by the business itself.
// 1. When a visitor lands from a tracked link, keep the click id.
// The tracked link adds ?ref=<click id>. Give each campaign's destination
// URL its tracking code too (for example ?yonto=YOUR_TRACKING_CODE), so
// your server knows which campaign the click belongs to.
app.use((req, res, next) => {
const ref = req.query.ref;
const code = req.query.yonto;
if (typeof ref === "string" && /^[0-9a-f-]{36}$/i.test(ref) && typeof code === "string") {
// Set by your server, not by a script, so a browser's limit on
// script-set cookies does not apply. Whether it needs the visitor's
// consent is your decision, as for any cookie of yours.
res.cookie("yonto_click", JSON.stringify({ ref, code }), {
httpOnly: true, secure: true, sameSite: "lax", maxAge: 365 * 86_400_000,
});
}
next();
});// 2. When the visitor signs up, logs in or checks out, store the click
// against the customer in your own database. From here it no longer
// depends on the browser at all: it survives cleared cookies and a
// different device, as long as they sign in.
async function rememberClick(req, customerId) {
const raw = req.cookies.yonto_click;
if (!raw) return;
const { ref, code } = JSON.parse(raw);
// This keeps the latest click. Keep the first instead if that is your rule;
// whichever you send is the click the sale is credited to.
await db.query(
"update customers set yonto_click_id = $1, yonto_tracking_code = $2, yonto_click_at = now() where id = $3",
[ref, code, customerId],
);
}// 3. Whenever the customer buys, a week or a year later, report the sale
// with the click id you kept.
async function reportSale(order) {
const c = await db.one("select yonto_click_id, yonto_tracking_code from customers where id = $1", [order.customerId]);
if (!c.yonto_tracking_code) return; // never came through a tracked link
const res = await fetch("https://yontosales.com/api/v0/conversions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.YONTO_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
tracking_code: c.yonto_tracking_code,
order_id: String(order.number),
order_value: order.total,
currency: order.currency,
click_id: c.yonto_click_id,
}),
});
// 422: the click is older than the business's click window. Nothing was
// recorded. Sent again without click_id, the sale is recorded as your own
// statement that it is this campaign's, and the report counts it as one.
if (res.status === 422) console.warn("click outside the window", await res.json());
}The example uses Express and SQL for brevity. Any server that can read a query string, write a row and send an HTTPS request works the same way.
Changing the click window#
The window is the business's, set in Settings beside the reporting timezone, and it is the same for every campaign so it can't favour one creator over another. When it is set above 30 days, Settings says which of the business's campaigns can credit a purchase that long after the click, from how each one reports. A change applies to sales from then on: a sale already counted stays counted, and a sale refused before isn't brought back. Each sale keeps the window it was judged under, and the report states the longest of those and the current setting. See how attribution works.