Tracking script
Goals
Add data-df-goal="name" to any element, or call window.datafair('goal', 'name', { plan: "pro" }). Extra attributes like data-df-goal-plan="pro" become properties.
Identify a customer
window.datafair('identify', { user_id, email, name }). Only send what your privacy notice covers.
Passing the visitor to checkout
window.datafair.attribution() returns df_visitor_id and df_session_id. Put them in your checkout's metadata. Links to Stripe payment links, Dodo Payments, Lemon Squeezy, Creem and Gumroad checkouts are tagged automatically.
Privacy controls
- Global Privacy Control is honoured unless you add
data-ignore-gpc. - With
data-consent="required"the script sets no cookies and sends nothing until you callwindow.datafair('consent', true). - Visit any page with
?df_ignore=trueto exclude your own browser.
Cookieless mode
Add data-cookieless to the script tag and nothing is stored in your visitors' browsers: no cookies and no local storage. DataFair works out a visitor id from a keyed hash of the day, your website, the visitor's IP address and their browser's user agent. The IP address itself is never stored, and the hash can't be turned back into it.
- The id changes every day, so a returning visitor counts as new each day, and visits from one day can't be joined to a payment on a later day.
- Payments made in the same day still match: checkout links are tagged with that day's id, and
window.datafair.attribution()returns it once the first pageview has been recorded. - People who share an IP address and the same browser version on the same day may count as one visitor.
- Whether you need a consent banner depends on your jurisdiction and what else your site does, so check with your own adviser.
Options
data-api: send events through your own proxydata-domain: set the cookie domaindata-cookieless: store nothing in the visitor's browser (see above)data-allow-localhost: allow local development