Appearance
Getting Started
Installation
Add the SDK script to your website's <head> section:
html
<script src="https://s3.us-east-2.amazonaws.com/cdn.rentmy.co/affiliate/prod/affiliate-sdk.min.js"></script>URL Parameters
The SDK reads these parameters from the page URL automatically during init():
| Parameter | Required | Example | Description |
|---|---|---|---|
ref | Yes (for affiliate tracking) | ref=HEWZRCKM | Affiliate code — triggers click tracking |
discount | No | discount=SUMMER20 | Discount code — stored in cookie for cart/checkout |
utm_source | No | utm_source=google | Traffic source |
utm_medium | No | utm_medium=cpc | Traffic medium |
utm_campaign | No | utm_campaign=spring-sale | Campaign name |
utm_content | No | utm_content=banner-ad | Ad content |
utm_term | No | utm_term=running+shoes | Search term |
gclid | No | gclid=Cj0KCQ... | Google click ID |
fbclid | No | fbclid=IwAR... | Facebook click ID |
msclkid | No | msclkid=abc... | Microsoft click ID |
Example affiliate link:
https://example.com/product/t-shirt?ref=HEWZRCKM&discount=SUMMER20&utm_source=google&utm_medium=cpc&utm_campaign=spring-saleOnce a user clicks this link, ref and discount are stored in cookies (30 days). All subsequent pages — cart, checkout, confirmation — read from cookies automatically. No URL params needed on those pages.
Page Type 1 — Initialization Page
This is the main page (or layout) where the SDK is loaded and initialized. Call init() once here using an async IIFE with onReady to signal readiness to all other scripts on the site.
javascript
(async function () {
try {
await window.AffiliateSDK.init({
apiKey: "as_XXXXYYYYZZZZ",
enablePageviews: true,
onReady: function () {
window._affiliateSDKReady = true;
},
});
} catch (err) {
console.error("AffiliateSDK init failed", err);
}
})();Page Type 2 — Sub-pages (Cart, Checkout, Product, etc.)
All other pages must wait for the SDK to finish initializing before calling any methods. Use the _affiliateSDKReady signal set by onReady on the init page.
javascript
(async function () {
const sdk = window.AffiliateSDK;
if (!sdk) return;
// Wait for SDK init to complete
await new Promise(function (resolve) {
if (window._affiliateSDKReady) return resolve();
var interval = setInterval(function () {
if (window._affiliateSDKReady) {
clearInterval(interval);
resolve();
}
}, 100);
});
// SDK is ready — call methods below
})();