← All docs

Configuration

Cookie Settings

SourceTag stores attribution data in a first-party cookie on your domain. This page covers the default settings, what the cookie contains, and how to change the configuration.

Default settings

SettingDefault valueDescription
Cookie name_sourcetagThe name of the cookie set on your domain
Cookie lifetime400 daysHow long the cookie persists in the browser
Cookie domainAuto-detectedSet to the root domain for subdomain support
Secure flagSet on HTTPSCookie only sent over encrypted connections
SameSiteLaxProtects against CSRF while allowing normal navigation
Session timeout30 minutes (1,800,000 ms)How long before a period of inactivity counts as a new session

Cookie configuration

The cookie name and lifetime are set automatically and no configuration is required.

Cookie name

The cookie is named _sourcetag.

Cookie lifetime

The cookie lifetime is 400 days. This means if a visitor comes to your site and doesn’t return for a year, their attribution data will still be available when they come back.

Note: Safari limits JavaScript-set cookies to 7 days via ITP regardless of this setting. Other privacy-focused browsers may impose similar restrictions. See Safari Cookies for details and workarounds.

Session timeout

The session timeout is 30 minutes, matching Google Analytics’ session definition. If a visitor is inactive for longer than this, their next page view counts as a new session, incrementing the st_visits counter. This value is not configurable.

Cookie domain

The cookie domain is auto-detected from the current hostname. SourceTag extracts the root domain (e.g. example.com from www.example.com or blog.example.com) and sets the cookie on .example.com. This means subdomains automatically share the same cookie without any manual configuration.

Secure flag and SameSite

On HTTPS sites, the cookie is set with the Secure flag, meaning it’s only sent over encrypted connections. The SameSite attribute is set to Lax, which prevents the cookie from being sent on cross-site requests (protecting against CSRF) while still allowing it to be sent on normal top-level navigations.

What the cookie stores

The _sourcetag cookie contains a JSON object with the following structure. You can inspect it in your browser’s developer tools (Application > Cookies).

Top-level keyDescription
fcFirst click touch data (set once, never overwritten)
lcLast click touch data (updated on each new visit with attribution data)
visitsTotal number of sessions
firstVisitTimestamp of the very first visit
lastSeenTimestamp of the most recent page view

Each touch object (fc and lc) contains: channel, d1-d4 (smart fields), source, medium, campaign, term, content, lp (landing page), clickId, clickIdType, clickIds, refDomain, ts (timestamp), and cp (custom parameters, if configured).

You can inspect the cookie in your browser dev tools: Application tab > Cookies > select your domain > find _sourcetag.

Note: The www. prefix is automatically stripped from referrer domains. A referrer of www.facebook.com is stored as facebook.com.

Key properties

  • fc (first click): The touch data from the visitor’s first-ever visit. This is set once and never overwritten.
  • lc (last click): The touch data from the most recent visit that had new attribution data (UTMs, click IDs, custom parameters, or an external referrer). Updated on each qualifying visit.
  • visits: Running count of sessions. Incremented each time the visitor returns after the session timeout has elapsed.
  • firstVisit: Unix timestamp (milliseconds) of the very first visit.
  • lastSeen: Unix timestamp (milliseconds) of the most recent page view. Used to calculate session boundaries.

Touch object properties

Each touch (fc and lc) contains:

PropertyDescription
channelCategorised channel name
d1 through d4Detail field values (content depends on channel)
sourceRaw utm_source value
mediumRaw utm_medium value
campaignRaw utm_campaign value
termRaw utm_term value
contentRaw utm_content value
lpFull landing page path and query string
clickIdPrimary click ID value
clickIdTypePrimary click ID type (gclid, fbclid, etc.)
clickIdsAll detected click IDs as key-value pairs
refDomainReferrer domain
tsTimestamp of this touch (Unix ms)
cpCustom parameter values as key-value pairs (only present if custom parameters are configured and detected in the URL)

Cookie size

The cookie is typically 1-3 KB depending on how much attribution data is captured. URL-encoded JSON can be larger. Browsers generally allow up to 4 KB per cookie, so this stays well within limits for most cases.

If you’re capturing very long campaign names or landing page URLs, keep an eye on the cookie size. You can inspect it in your browser’s developer tools under Application > Cookies.

Cookie scope

The cookie is set with path=/, SameSite=Lax, and the Secure flag (on HTTPS sites). The cookie domain is auto-detected to the root domain. This means:

  • It’s accessible on all pages of the current domain and its subdomains
  • It’s not sent on cross-site requests (protecting against CSRF)
  • On HTTPS, it’s only transmitted over encrypted connections
  • It’s a first-party cookie (set by JavaScript running on your domain)

The cookie does not cross between different top-level domains. If you run example.com and myotherbrand.com, each will have its own cookie. However, subdomains like www.example.com and blog.example.com share the same cookie automatically. See Cross-Domain and Subdomains for more detail.

Doesn't answer your question or need more help? Get in touch.