Embed it
Paste the loader script inside your authenticated app, with a publishable key. It injects an auto-resizing iframe:GET /api/v1/referrals/stats,
which auto-enrolls the user (idempotent — same as
POST /api/v1/referrals/enroll), so there is
nothing else to wire up.
Attributes
string
required
A publishable key (
pk_…) from Settings → Developers. Safe to expose in the browser.string
required
The user’s id in your system — becomes their
external_user_id.string
The user’s email. Recommended — it’s used as the partner identity.
string
default:"free"
free or paid — decides which credit amount applies.string
A CSS selector (e.g.
#refer-earn) to render the dashboard into. If omitted, the dashboard
renders where the script tag sits.string
default:"light"
light or dark.string
A hex brand color for the dashboard’s accent, e.g.
#6366f1.number
default:"30"
The analytics window in days,
7–90.string
Only for custom deployments — the API origin to call. Defaults to the script’s own origin.
Direct iframe
Prefer not to load a script? Point an iframe straight at the embed page and pass the same values as query parameters (accent without the #):
key— the publishable key (required).uid— the user’s id in your system (required).email— the user’s email (recommended).tier—freeorpaid(defaultfree).theme—lightordark(defaultlight).accent— hex color without the#, e.g.6366f1.days— analytics window, 7–90 (default 30).
Auto-resizing
The iframe posts its content height to the parent window so you can size it without scrollbars:embed.js loader listens for these messages and resizes the iframe automatically. If you use
the direct iframe, add a small message listener yourself and set the iframe’s height from
event.data.height when event.data.type === "trackrev:embed:height".
Theming
Usedata-theme (light | dark) to match your app’s mode and data-accent to apply your brand
color to buttons, links and highlights. With the direct iframe, the same options are the theme
and accent query params (accent without the #).
Affiliate upgrade
The embed can offer end-users a choice of how they’re rewarded:- Referrer (default) — earn credits, exactly as today.
- Affiliate — earn direct cash commissions at the program’s commission rate, with payout access, without ever leaving your app. (Partners who join via the public join page are affiliates only — this toggle is how your own users get there in-product.)
- The merchant enabled Allow customers to become affiliates in the program settings
(
programs.allow_affiliate_upgrade), and - the program is credit-based (
credit_enabled). Cash-based programs already pay cash — no toggle is shown.
commission_type / commission_rate — merchants set this
commission alongside the toggle in the program settings.
Switching affects future conversions only — credits already earned are kept — and is fully
reversible. While in affiliate mode, the embed swaps in an embedded portal view: cash balance
(pending / eligible / paid), recent commissions, payout-method setup, payout history, and the
program’s minimum payout threshold.
The stats response reflects the current mode: it gains a top-level reward_mode
("referrer" | "affiliate") and an affiliate object (allowed, min_payout,
payout_method, recent_commissions, payouts) — see
GET /api/v1/referrals/stats.
Set reward mode
POST /api/v1/referrals/reward-mode — switch a user between referrer and affiliate mode. Also
available in the endpoint reference.
string
required
The user’s id in your system.
string
required
referrer or affiliate.cURL
Response
403 forbidden when the program doesn’t allow the upgrade, 400 bad_request for an
invalid mode or missing id.
Set payout method
POST /api/v1/referrals/payout-method — save where an affiliate-mode user gets paid. Only
accepted while the enrollment is in affiliate mode (403 forbidden otherwise). Also in the
endpoint reference.
string
required
The user’s id in your system.
string
required
The payout method, e.g.
paypal.string
The PayPal address to pay, when
method is paypal.cURL
Response
Under the hood
The dashboard is powered by a single endpoint you can also call yourself:GET /api/v1/referrals/stats — windowed
stats, lifetime rewards and a daily series, with auto-enrollment built in. Use it directly if you
want the numbers in your own UI.
