Skip to content

The clickid module ​

Part of the SharedID Edge specification. The general rules for modules, including consent, time limits and modules on /sync, are there.

Name clickid; no gvlid, and no declared purposes (it checks Purposes 1 and 7 itself, below, so it can delete what it stored). It runs only when listed in SID_MODULES. It keeps ad click IDs from the landing page's URL in server-set first-party cookies, so a conversion on a later page view or visit can be attributed.

  • Settings, SID_MODULE_CONFIG.clickid, every key optional:

    • params: a list of entries { "name", "cookie"?, "enabled"? }. The default parameters are gclid, gbraid, wbraid, dclid, fbclid, msclkid and ttclid, in that order, each kept in the cookie _sid_<name>. An entry whose name is a default parameter changes it; any other entry adds a parameter after the defaults, in list order. name (required) is a query parameter name matching ^[A-Za-z][A-Za-z0-9_-]{0,63}$, matched case-sensitively, and MUST NOT repeat in the list. cookie (default _sid_<name>), given or defaulted, is a cookie name (an RFC 6265 token, at most 64 characters) and MUST NOT be _pubcid, _pubcid_sv, _pubcid_optout, ts-ec, euconsent-v2 or _sid_keep (nor, as for every module, the worker's configured cookie names). enabled (default true) set to false turns the parameter off. At most 20 parameters may be enabled, and no two may use the same cookie;
    • maxAgeDays (default 90): an integer from 1 to 400;
    • domain: a registrable domain without a leading dot, such as example.com, and the cookies get Domain=.<domain>; or host-only, and they get no Domain attribute whatever SID_COOKIE_DOMAIN says; or auto, and they get the domain Prebid.js reports on the request (cookie_domain, checked against the host as for SID_COOKIE_DOMAIN=auto), else no Domain, whatever SID_COOKIE_DOMAIN says; a deletion (on opt-out, or when storage isn't allowed) goes to the host and every domain above it. Without it, SID_COOKIE_DOMAIN applies;
    • httpOnly (default false);
    • hosts: up to 20 lower-case hostnames, besides the request's own, whose URLs are read (a browser request from another site is refused whatever its URL, below).

    Any other key, a wrong type or an out-of-range value makes the module an error on every call, with no details; error messages MUST NOT contain configured values.

  • The landing URL is the request's url query parameter when it's present and non-empty, else its Referer header. It's used only when it parses as an absolute http or https URL whose host, compared case-insensitively, is the request's own host or one of hosts; otherwise there's no landing URL and nothing is stored. There's also none when the request comes from another site: it has Sec-Fetch-Site: cross-site, or a non-empty Referer that isn't such a URL (even when the url parameter is used). A url naming an allowed host says nothing about where the request came from, so without this a link on another site to {basePath}/v1?url=… could plant a click ID. On /sync (Prebid.js's pixelUrl, an image request from the page) the Referer is the landing page under the browser's default referrer policy.

  • Click IDs: for each enabled parameter, the first value of that parameter in the landing URL's query, after one round of application/x-www-form-urlencoded decoding (so + is a space). It's used only when it matches ^[A-Za-z0-9._~-]{1,512}$; otherwise it's ignored, never rewritten, and a later value of the same parameter isn't tried.

  • Storing: for each click ID, the module sets <cookie>=<t>.<id>; Max-Age=<maxAgeDays × 86400>; Expires=…; Path=/; [Domain=.<domain>;] SameSite=Lax; [Secure;] [HttpOnly], where <t> is the current time in whole Unix seconds and <id> the click ID unchanged. When the request already carries the cookie with a value of the form <digits>.<id> for the same <id>, it's not set again: the lifetime counts from the click and isn't refreshed by later visits. A different click ID for the same parameter replaces it. Cookies of parameters without a click ID in the URL are left alone.

  • Output: cookies only, so the status is empty. Click IDs MUST NOT appear in eids, ortb2, ext or anywhere else in the payload or headers.

  • Consent: click IDs are stored only when all of these hold; otherwise nothing is stored, and the module deletes each cookie of its configuration (enabled parameters, and parameters listed with enabled: false) the request carries, with Max-Age=0 and the configured Domain and HttpOnly:

    • storage.allowed is true (so not on opt-out, Sec-GPC: 1, coppa=1, a TC string that doesn't give the SharedID's consent, or GDPR applying without a TC string);
    • the US Privacy string, from the us_privacy parameter, else the usprivacy cookie (the IAB CCPA framework's first-party cookie), doesn't have Y (in either case) as its third character, an opt-out of sale;
    • when the request has a TC string, or GDPR applies, the TC string's publisher TC segment consents to Purposes 1 and 7.
  • Opt-out: {basePath}/optout deletes each cookie of the module's configuration the browser sent, whether or not clickid is in SID_MODULES.

  • Caching: every result has noStore: true, so a /sync it runs on is Cache-Control: no-store (see Modules on /sync). A browser caches a sync by its URL, whatever page requested it, so a cached sync would hide every landing page until it expired. With SID_SYNC_MODULES leaving clickid out, syncs are cached as usual, and only /v1 stores click IDs.

  • Its routes are v1 and sync.