RekomiRekomiBlogPricing
Rekomi Docs
Rekomi Docs
Welcome to Rekomi
API overviewAuthenticationOAuth 2.0Server-to-server trackingTracking script & window.RekomiNo-code & non-Stripe checkoutsCustom domainConversion currencyCoupon code trackingSub-affiliate recruiting APIWebhooksZapierWhite-label embedMCP serverAPI reference
For developers
|Developers|

Tracking script & window.Rekomi

Install the Rekomi browser loader and read the referral context (affiliate + campaign) on page load, in real time.

The Rekomi tracking script (loader.js) does two things:

  1. Captures the click — reads the affiliate attribution param from the URL (?via=, ?ref=, ?fpr=, etc.) into a first-party cookie + localStorage and records the click.
  2. Exposes window.Rekomi — a small JavaScript object so your site can read the referral context (the affiliate's name and the campaign name, not just a slug) on page load. This is what you use to show "Referred by …", or to capture the referring affiliate on your signup form in real time.

Migrating from Rewardful?

This is the direct replacement for reading window.Rewardful.affiliate / window.Rewardful.campaign at signup. window.Rekomi now exposes the same referral / affiliate / campaign shape — see Capture the affiliate + campaign on load.

Install

Paste this on every page of your site, in <head>:

<script async
  src="https://api.rekomi.com/api/v1/r/loader.js"
  data-program-id="{your_program_id}"></script>

Copy the exact snippet (with your real data-program-id and any custom attribution params) from Dashboard → Settings → Tracking script. If you have a verified custom domain, the snippet loads from your own subdomain instead of api.rekomi.com.

The window.Rekomi object

Once the script loads it defines window.Rekomi. The slug is available immediately; the affiliate and campaign objects are filled by one lightweight async lookup, so read them inside ready().

Properties

PropertyTypeDescription
referralstring | nullThe affiliate's referral slug, e.g. "b7pa99hvx7zx". null if the visitor wasn't referred.
affiliate{ id, name } | nullThe referring affiliate's id + display name once resolved. null if no referral.
campaign{ id, name } | nullThe campaign's id + name once resolved. null if no referral.

Methods

MethodDescription
ready(callback)Runs callback(window.Rekomi) once the referral context is resolved. Fires immediately when there is no referral (or it's already resolved). Use this to read affiliate / campaign reliably.
getReferral()Returns the slug synchronously (URL param → localStorage → cookie), or null. Available instantly, no wait.
clearReferral()Clears the stored slug and the resolved referral / affiliate / campaign.

Capture the affiliate + campaign on load

This is the recommended pattern to capture who referred a signup, client-side, the moment the page loads — no backend integration required:

<script>
  window.Rekomi.ready(function (R) {
    if (!R.referral) return; // visitor was not referred

    // R.referral  -> "b7pa99hvx7zx"
    // R.affiliate -> { id: "...", name: "Milo Okha" }                (or null)
    // R.campaign  -> { id: "...", name: "Viraly Affiliate Program" } (or null)

    myApp.setReferral({
      referral:      R.referral,
      affiliateName: R.affiliate ? R.affiliate.name : null,
      campaignName:  R.campaign  ? R.campaign.name  : null
    });
  });
</script>

Then send those fields to your backend when the user signs up. Because ready() waits for the lookup, affiliate.name and campaign.name are populated even if you read them right after page load.

Read affiliate/campaign inside ready()

getReferral() and R.referral (the slug) are synchronous. R.affiliate and R.campaign are filled after a short async lookup — if you read them on the bare window.Rekomi object immediately, they may still be null. Always read them inside a ready() callback.

Server-side alternative

If you'd rather resolve a slug from your backend, the same data is available from a public endpoint:

GET https://api.rekomi.com/api/v1/r/resolve?via=SLUG[&program=PROGRAM_ID]
{
  "referral": "b7pa99hvx7zx",
  "affiliate": { "id": "6be0bba5-…", "name": "Milo Okha" },
  "campaign":  { "id": "cd1a591e-…", "name": "Viraly Affiliate Program" }
}

Returns 404 for an unknown or suspended slug. The optional program param is your data-program-id; include it so account-level slugs resolve to the right program.

What's exposed (and what isn't)

Exposed client-side: the affiliate's display name and the campaign name — the same info shown on your public signup / recruiting pages. Not exposed: the affiliate's email or any other PII. Fetch those server-side from the authenticated REST API (e.g. the conversions feed returns affiliateEmail and stripeCustomerId).

Single-page apps

window.Rekomi persists across client-side route changes, so it's initialized once on the first page load. If your signup form mounts after a route change, register a ready() callback when that component mounts (or cache the values in app state on first load) rather than relying on the script re-running.

Conversion tracking

This script handles click attribution and the referral context only. Conversions are tracked automatically by your payment processor (Stripe, Paddle, Braintree, Shopify) or via the S2S API — there is no browser-side convert() call to make.

Server-to-server tracking

HMAC-signed conversion ingest for any payment gateway beyond the native Stripe, Paddle, Braintree, and Shopify connections.

No-code & non-Stripe checkouts

Install the Rekomi tracking script for click attribution on a no-code platform, and record conversions via a native processor, the S2S API, or coupon codes.

On this page

InstallThe window.Rekomi objectCapture the affiliate + campaign on loadServer-side alternativeWhat's exposed (and what isn't)Single-page appsConversion tracking