SmoothProfitDocs
ProductStart free

Getting started

  • Introduction
  • Quickstart
  • Authentication
  • Errors & rate limits

Core concepts

  • Tenancy model
  • Attribution
  • Commission resolution
  • Payout lifecycle

Guides

  • Install the tracker
  • Connect a storefront
  • Affiliate storefronts

API reference

  • Context
  • Affiliates
  • Conversions
  • Landing pages
  • Coupons
  • Payouts
  • Providers
  • Tracking

Guides

Install the tracker

A first-party script that reads ?ref=, records the click, and keeps the attribution in a cookie until checkout.

The basic install

html
<script
  src="https://app.smoothprofit.app/tracker/smoothprofit.js"
  data-program="peakcare"
  data-api-base="https://app.smoothprofit.app"
  async
></script>

Put it on every page a referral link can land on — including the home page, since affiliates share whatever URL they like.

Attributes

data-programRequired. Your program's subdomain.
data-api-baseRequired. Your SmoothProfit origin.
data-cookie-domainSet to ".brand.com" so subdomains share the cookie.
data-cross-domainsComma-separated hosts to decorate links and forms for.

When checkout is on a subdomain

Cookies set without an explicit domain are host-only, so an attribution written on brand.com is invisible on checkout.brand.com. This is the single most common reason attribution silently stops working. Set the registrable domain with a leading dot:

html
data-cookie-domain=".brand.com"

When checkout is a different domain entirely

No cookie can span two registrable domains. List the hosts and the script rewrites outbound links and form posts to carry sp_ref and sp_click; the tracker on the receiving domain adopts them without recording a duplicate click.

html
data-cross-domains="checkout.otherbrand.com,pay.example.com"
Only real <a> clicks and <form> submits are intercepted. A JavaScript-driven window.location = ... redirect bypasses it — read the sp_ref cookie and append the parameters yourself before redirecting.

Reading the attribution

Client-side, once the script has loaded:

js
const attribution = window.smoothprofit?.getAttribution();
// { referralCode: "a8f2k1x9", clickId: "4b91..." } or null

Server-side, parse the sp_ref cookie. Prefer this: it works no matter which checkout flow runs, including ones you add later.

Verifying the install

  • Visit any page with ?ref= and a real referral code.
  • Confirm an sp_ref cookie appears with both fields populated.
  • Confirm the affiliate's click count increments on dashboard-summary.
  • Complete a test order and confirm the conversion attributes to that affiliate.
The script never blocks or breaks the host page: every failure path is swallowed. That also means a broken install fails silently — check the cookie rather than assuming.