Afflixo

Merchant user guide

How to use this system and report clicks and conversions quickly. For technical endpoints see API reference.

Step 1: Get your Merchant Slug (integration key)

Use the Merchant Slug for integration; no separate API key. How to get it:

  • At registration — On Register, enter your website URL (e.g. https://yoursite.com). The system derives a slug (e.g. yoursite). After signup you are redirected to /domain/yoursite/dashboard; the segment yoursite is your Merchant Slug.
  • After login — The browser URL is /domain/<merchantSlug>/dashboard. The middle segment is your Slug.
  • In settings — Open Merchant Settings (e.g. /domain/<slug>/settings) to see the read-only Slug field.

Step 2: Add the tracking script (recommended)

Add the script on every page (or at least landing and checkout) to record visits with ref=CODE and set the cookie for conversion attribution.

Script URL:

https://afflixo.com/sdk.js?merchant=<merchantSlug>

Example: https://afflixo.com/sdk.js?merchant=reviewgrow

<!-- Replace YOUR_MERCHANT_SLUG with your merchant slug from the dashboard -->
<script
  src="https://afflixo.com/sdk.js?merchant=YOUR_MERCHANT_SLUG"
  async
></script>

The script reads ref= from the URL, calls the track click API and sets the cookie, and exposes window.Affiliate.getAffiliateCode(), window.Affiliate.onReady(callback), and window.Affiliate.trackConversion(...). Use onReady(callback) to get the affiliate code after the page (and any click tracking) has finished: the callback runs when the SDK is ready and, if the visitor came via ref=CODE, after the cookie is set — so getAffiliateCode() will return the code inside the callback. Try the Integration demo to see a minimal working example.

Get affiliate code after page load:

window.Affiliate.onReady(function() {
  var code = window.Affiliate.getAffiliateCode();
  if (code) {
    // Visitor came via ?ref=CODE — use code for conversion or display
  }
});

Step 3: Report conversions (choose one)

Report one conversion per completed order so affiliates get commission. Either:

Where to put it (thank you / success page)

Yes — call trackConversion on the order success page: static thank-you URL (e.g. /thankyou?orderId=…), payment gateway return URL, or the SPA route shown after payment succeeds. Include the same sdk.js snippet on that page so affiliate_ref is available (heartbeat alone does not record a conversion).Amount must be a real number from your server or order API; the query string usually only has orderId, so render a small JSON blob from the backend or fetch order details before calling trackConversion.

  • Front-end — On that page, use onReady so the affiliate cookie is visible after click tracking, then call trackConversion only when getAffiliateCode() is set (avoids 400 for non-affiliate orders). Fields:
    • orderId (required), amount (required, number), currency (optional, default "USD")
    • affiliateCode (optional — from cookie if omitted), transactionId (optional), email (optional), productName (optional), note (optional, max 1000 chars)
    Example for a thank-you page with ?orderId= and order totals injected by your template (replace how you pass amount / currency to match your stack):
    // From server-rendered page: e.g. var ORDER = { id: "32095", amount: 49.99, currency: "USD" };
    // Or read orderId from URL and fetch GET /api/orders/:id then call trackConversion in the fetch callback.
    (function () {
      var params = new URLSearchParams(window.location.search || '');
      var orderId = params.get('orderId');
      if (!orderId) return;
    
      window.Affiliate.onReady(function () {
        if (!window.Affiliate.getAffiliateCode()) return;
    
        var amount = window.__ORDER__ && typeof window.__ORDER__.amount === 'number'
          ? window.__ORDER__.amount
          : null;
        var currency = (window.__ORDER__ && window.__ORDER__.currency) || 'USD';
        if (amount == null) {
          console.warn('Affiliate: set window.__ORDER__ = { amount, currency } from your server or fetch order before trackConversion');
          return;
        }
    
        window.Affiliate.trackConversion({
          orderId: String(orderId),
          amount: amount,
          currency: currency
        }).catch(function (err) { console.warn('Conversion track failed', err); });
      });
    })();
    Minimal shape if you already have variables in scope:
    window.Affiliate.onReady(function () {
      if (!window.Affiliate.getAffiliateCode()) return;
      window.Affiliate.trackConversion({
        orderId: 'YOUR_ORDER_ID',
        amount: 99,
        currency: 'USD'
      }).catch(function (err) { console.warn('Conversion track failed', err); });
    });
    Without the getAffiliateCode() check, non-affiliate orders would send a request that returns 400 and the promise rejects.
  • Back-end — Your server calls POST /api/<merchantSlug>/track/conversion when the order completes, with orderId, amount, currency? (default USD), and affiliateCode (from the front end via cookie or getAffiliateCode()). Duplicate orderIds are idempotent and do not double-count commission.

Request/response format: API reference — Report conversion.

Click tracking is handled by the script automatically: it only sends a click when the URL has ref= or when the referrer is from a different origin (external site). Same-site navigation does not trigger a click, so you do not need to add any check before the script runs.

Step 3b: Track customer signups (optional)

To record customer signups attributed to affiliates (so merchants and affiliates can see them in the dashboard — no commission), call window.Affiliate.trackSignup(...) when a user completes registration. Use a unique signupId per signup (e.g. user id or email) for idempotency. Optional role (e.g. "free", "premium") lets you filter and sort signups by role in the dashboard.

if (window.Affiliate.getAffiliateCode()) {
  window.Affiliate.trackSignup({
    signupId: 'USER_ID_OR_EMAIL',   // required, unique per signup
    email: '[email protected]',  // optional, visible to merchant only
    role: 'premium'                 // optional, for filter/sort in dashboard
  }).catch(function(err) { console.warn('Signup track failed', err); });
}

Or call POST /api/<merchantSlug>/track/signup from your back-end with signupId, affiliateCode (or use cookie/header), and optional email and role. See API reference — Report signup.

Summary

  1. Get your Merchant Slug (register / login / settings).
  2. Add sdk.js?merchant=<slug> site-wide (or on key pages) to record clicks and set the cookie.
  3. Report one conversion per order using front-end trackConversion (only when getAffiliateCode() is set) or back-end POST /track/conversion.
  4. Optionally report customer signups with trackSignup so merchants and affiliates can see signup records.

Referral link format: your site URL + ?ref=CODE, e.g. https://yoursite.com/?ref=AF123456. Affiliates get their code and link from the Affiliate dashboard.

Referrer domains (clean links)

Affiliates can optionally add a list of referrer domains (e.g. their blog or site) in My links. When your site uses the tracking script and a visitor arrives without ref= in the URL but came from one of those domains, the script sends the referrer to the backend; if it matches an affiliate’s approved domain, the visit is attributed to that affiliate. That allows clean links like https://yoursite.com instead of https://yoursite.com/?ref=AF123456. Attribution by referrer depends on the browser sending the referrer; if it is stripped (e.g. Referrer-Policy or privacy tools), the ref= link remains the most reliable. New domains may be auto-approved or require merchant approval (see platform admin config and merchant Referrer domains in the dashboard).

Merchant dashboard

After login, go to /domain/<merchantSlug>/dashboard to:

  • Affiliates — View, approve, enable or disable affiliates.
  • Referrer domains — When platform auto-approve is off, approve or reject affiliates’ referrer domains for clean-link attribution.
  • Conversions — View conversions and commission status (pending / approved / paid).
  • Payouts — Process payout requests; actual payment is done outside the system.
  • Settings — Configure commission, attribution, website URL, cookie duration, etc.

More APIs

To fetch affiliate list, single affiliate earnings, or payouts from your own system, use the Merchant API in the API reference (login required for JWT).