Install tracking
Two steps: one script tag on your site, and one call from your server when an order completes. That is everything Amblify needs to credit the right ambassador for visits and sales.
1. Install the snippet
Paste this tag once, on every page of your site, ideally just before </head>. It loads asynchronously and never throws inside your page.
<script async src="https://amblify-backend.guud.ai/track.js"></script>
Because your brand is guud-owned, the tag above pre-binds your brand slug () so the same tag works on every one of your sites.
What it does
- Reads
?amb=<username>from the landing URL. Every link an ambassador shares for you carries it. - Stores the username in a first-party cookie named
amb_reffor 30 days. First touch wins: the ambassador who brought a visitor first keeps the credit. - Beacons one visit per session to Amblify. Bot traffic and non-US visitors are dropped server-side, and repeat visits from the same device are deduplicated per day.
- Exposes
window.amblifywithambassadorandcustomIdso your checkout can read who referred the customer.
No API key is needed in the browser. The snippet is public and safe to ship on any page.
2. Test a tracked link
Open your site with an amb parameter, then check the cookie in your browser's dev tools. Use any real ambassador username, or your own if you also have a creator account.
https://your-site.com/?amb=creator_username
document.cookie.match(/amb_ref=([^;]*)/)?.[1] // → "creator_username"
window.amblify // → { brand, ambassador, customId }
Visits only count from US IP addresses in a real browser. Automated browsers and headless tools are ignored, so use a normal browser tab to test.
3. Report conversions from your server
When an order completes, read the amb_ref cookie (or the amb value you saved at checkout) and call the conversion endpoint from your server. Amblify looks up the ambassador's commission bounty with your brand, computes the commission owed, and adds it to your monthly invoice.
| Field | Required | Meaning |
|---|---|---|
order_id | yes | Your own order id. Also the idempotency key: retrying the same id returns the original conversion with duplicate: true. |
amount | yes | Order total as a decimal number, e.g. 49.99. |
amb | yes | The ambassador username from the amb_ref cookie. |
currency | no | ISO code, defaults to USD. |
campaign_id | no | Pin the conversion to one of your bounties. Otherwise the ambassador's highest-rate verified commission bounty with you is used. |
Option A: bearer token (simplest)
Send your secret track key as a bearer token. Keep the key in your server's environment, never in a page.
curl -X POST https://amblify-backend.guud.ai/api/track/conversion \
-H "Authorization: Bearer $AMBLIFY_TRACK_KEY" \
-H "Content-Type: application/json" \
-d '{"order_id":"ORD-10042","amount":49.99,"amb":"creator_username"}'
Option B: signed request (key never leaves your server)
Send your public brand slug plus an HMAC-SHA256 signature of the exact request body, computed with your track key. Amblify verifies the signature so the key itself is never transmitted.
const crypto = require('node:crypto');
async function reportConversion({ orderId, amount, amb, campaignId }) {
const body = JSON.stringify({ order_id: orderId, amount, amb, campaign_id: campaignId });
const signature = crypto
.createHmac('sha256', process.env.AMBLIFY_TRACK_KEY)
.update(body)
.digest('hex');
const res = await fetch('https://amblify-backend.guud.ai/api/track/conversion', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Amblify-Brand': process.env.AMBLIFY_BRAND_KEY, // your public brand slug
'X-Amblify-Signature': 'sha256=' + signature,
},
body,
});
return res.json(); // { ok, conversion: { attributed, commission, duplicate?, ... } }
}
$body = json_encode(['order_id' => $orderId, 'amount' => $amount, 'amb' => $_COOKIE['amb_ref'] ?? null]);
$sig = hash_hmac('sha256', $body, getenv('AMBLIFY_TRACK_KEY'));
$ch = curl_init('https://amblify-backend.guud.ai/api/track/conversion');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Amblify-Brand: ' . getenv('AMBLIFY_BRAND_KEY'),
'X-Amblify-Signature: sha256=' . $sig,
],
]);
$result = json_decode(curl_exec($ch), true);
Responses
- 201 with
conversion.attributed: trueand the commission owed, when the ambassador has a verified commission bounty with you. - 201 with
attributed: falseandreason: no_commission_claimwhen they do not. The sale is still recorded, nothing is owed. - 200 with
duplicate: truewhen you resend anorder_idalready reported. - 401 / 403 when the key or signature is wrong. 404 when
ambis not a known ambassador.
Running the always-on affiliate program (signups, subscription payments, refunds)? Send event bodies to the same endpoint with the same auth: see Affiliate events in the API docs.
Selling with PayPal buttons or subscriptions?
You can skip step 3. Pass the value the snippet exposes as window.amblify.customId into your PayPal button's custom_id, and Amblify's PayPal webhook credits the ambassador on every completed sale and each subscription renewal.
paypal.Buttons({
createOrder: (data, actions) => actions.order.create({
purchase_units: [{
amount: { value: '49.99' },
custom_id: (window.amblify && window.amblify.customId) || undefined, // "amb=<username>;brand=<your-slug>"
}],
}),
}).render('#paypal-button');
For subscriptions, set the same value as custom_id on actions.subscription.create. Renewals are credited every billing cycle for as long as the subscription stays active.
Your PayPal setup
Log in as a brand and this section fills in with your own script tag, custom_id value and a ready-to-run conversion call, pre-filled from GET /api/track/snippet.
Everything below is pre-filled for your brand. The script tag and custom_id contain no secret and are safe to paste into any page.
The cURL example carries your secret track key. Run it from your server or terminal only, never from a page. The webhook that credits PayPal sales is ; Amblify manages it for you, nothing to configure in PayPal.
guud-owned sites
Sites that guud runs on your behalf can skip host matching and pre-bind your brand in the tag itself. Every guud site then pastes this one identical line:
The ?brand= binding only takes effect for brands guud owns. On other brands the parameter is ignored and the visit is matched to your site URL instead.
Selling on Shopify?
You can skip step 3 here too. Add one Shopify webhook and Amblify credits the referring ambassador on every paid order. The ambassador is read from a cart attribute named amb_ref (copy the snippet's cookie into it from your theme) or, failing that, from the ?amb= on the landing URL Shopify recorded.
Log in as a brand to save your Shopify signing secret and get your webhook URL.
Setup in Shopify admin › Settings › Notifications › Webhooks
- Scroll to the bottom of the Webhooks page and copy the signing secret (“Your webhooks will be signed with …”). Paste it below and save.
- Click Create webhook. Event: Order payment (topic
orders/paid), format JSON, URL: the webhook URL shown below once saved. - Save, then click Send test. Real paid orders are credited from then on; retries of the same order are ignored.
Topic: orders/paid (shown as “Order payment” in Shopify). Format: JSON.
Selling on WooCommerce?
Same deal as Shopify: skip step 3 and add one WooCommerce webhook. Amblify credits the referring ambassador when an order turns Processing or Completed; later edits of the same order are ignored, so a sale is never counted twice. The ambassador is read from an order meta field named amb_ref (have your checkout copy the snippet's amb_ref cookie into it).
Log in as a brand to save your WooCommerce webhook secret and get your webhook URL.
…
Setup in WordPress admin › WooCommerce › Settings › Advanced › Webhooks
- Choose a secret (any random string, 8 to 200 characters), paste it below and save. WooCommerce does not generate one for you.
- Click Add webhook. Name: Amblify, Status: Active, Topic: Order updated, Delivery URL: the webhook URL above, Secret: the same secret you saved here, API version: WP REST API Integration v3.
- Save the webhook. WooCommerce sends a test ping that Amblify accepts; real paid orders are credited from then on.
Deliveries are signed with X-WC-Webhook-Signature; until a secret is saved here they are rejected.
Your track key
Server-side onlyLog in as a brand to reveal your track key and brand slug here. The key is secret: store it in your server's environment as AMBLIFY_TRACK_KEY and never put it in a web page or mobile app.
Signed in as your brand. Store these in your server's environment. Never ship the track key in a page or app.
AMBLIFY_BRAND_KEY=…
AMBLIFY_TRACK_KEY=amb_tk_••••••••••••••••••••••••••••••••••••••••••••••••
Fetched from GET /api/brands/me/track-key with your brand session. If the key ever leaks, contact Amblify to rotate it.
Questions? Reply to your invoice email or reach the team from the brands page.