AffiliateTracker
Guide · Getting started

Connecting a site without a module

For sites on other platforms or custom-built: one line in the pages for clicks, one call from your server for orders, one line for the affiliate area.

If your shop is not on PrestaShop, WooCommerce or Shopify you can still connect it. You need someone who can edit the site's pages and the code that handles orders. At signup, or from Shops & module, choose Another site (API integration).

1. Paste the snippet in your pages

In Shops & module you find the line ready to copy, with your shop's public key. It goes in every page, before </head>:

<script async src="https://affiliatetracker.it/at.js" data-key="atpk_…"></script>

When a visitor arrives from an affiliate link (?referral=CODE, with &camp=campaign if present), the snippet records the click and remembers the code in a cookie on your site, at_ref, for the duration you chose in Settings.

The snippet only works from pages on the address registered for the shop (with or without www). The public key is not a secret: on its own it can't read or write your data.

The cookie and the click record are marketing. If you load the snippet only after consent (from a tag manager, for instance) there is nothing else to do. Otherwise add data-consent="wait": the snippet writes and sends nothing until your banner tells it to.

<script async src="https://affiliatetracker.it/at.js" data-key="atpk_…" data-consent="wait"></script>

// where your banner reports the marketing choice
AffiliateTracker.consent(true);   // accepted
AffiliateTracker.consent(false);  // refused or withdrawn: clears what was remembered

If the snippet may not be loaded yet at that point, wait for the affiliatetracker:ready event on document.

3. Send the order from your server

At checkout, read the affiliate code and store it with the order. In the browser use AffiliateTracker.getReferral() and AffiliateTracker.getCampaign() (for example into a hidden field of the order form); on the server you can read the at_ref cookie, which holds a JSON with ref and camp.

When the order is confirmed, your server reports it with the shop's API key. That one is secret: it must never appear in page code.

curl -X POST https://affiliatetracker.it/api/v1/webhooks/orders \
  -H "X-AT-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "order.created",
    "order": {
      "external_id": "10432",
      "state": "pending",
      "referral_code": "MARIO10",
      "campaign": "instagram-november",
      "external_customer_id": "8841",
      "customer_email": "customer@example.com",
      "currency": "EUR",
      "total_paid": 84.90,
      "total_products": 75.00,
      "total_products_nodiscount": 75.00,
      "total_shipping": 9.90,
      "discount_codes": ["MARIO10"]
    }
  }'
external_id
Required. The order number in your site: the same you will use for status changes.
state
pending, approved or cancelled. An order that is already paid can be created as approved.
referral_code, campaign
What the snippet remembered. Leave them out if the order doesn't come from an affiliate.
external_customer_id
The customer's identifier in your site. Needed by the attribution modes that tie the customer to the affiliate.
total_paid
Total paid, tax and shipping included.
total_products
Products only, net of discounts. total_products_nodiscount: only products not on sale.
total_shipping
Shipping.
discount_codes, customer_email
The discount codes used and the customer's email: needed for influencer discount codes.
currency
The currency charged (ISO 4217). If missing, the shop's currency applies.

The response is { "ok": true, "processed": true, "reason": "…" }. You can send every order, including those with no affiliate: a commission is created only when your programme's rules call for it. Repeating the same call creates no duplicates, so on a network error just retry.

401: wrong API key. 402: subscription not active. 400: event or order.external_id is missing.

4. Report payments and cancellations

The commission stays pending until you report that the order is valid, and is reversed if the order is cancelled or returned:

curl -X POST https://affiliatetracker.it/api/v1/webhooks/orders \
  -H "X-AT-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "event": "order.status_changed", "order": { "external_id": "10432", "state": "approved" } }'

approved confirms the commission, cancelled cancels it (even after confirmation). A partial return has no state of its own: correct the amount with an adjustment from the dashboard.

5. Put the affiliate area in your site

Create a page in your site, for example "Affiliates", and paste this line where the area should appear. You find it ready in Shops & module:

<script async src="https://affiliatetracker.it/widget.js" data-key="atpk_…"></script>

Whoever opens the page enters their email and receives a link to get in: no password to remember. People who are not affiliates yet fill in the application, which you approve or reject from the dashboard; affiliates find their link to share, clicks, orders, pending and confirmed commissions, payments received and the IBAN form.

The link in the email takes the affiliate back to your page and is valid for 30 minutes. After that they stay signed in on that device for 30 days; some browsers (Safari in particular) may ask for a new link sooner. The area can only be shown from pages on the address registered for the shop.

6. What differs from a module

Affiliates, commissions, levels, campaign links, reports and payments are managed from the dashboard as for any other shop. Three things are different:

  • influencer discount codes must be created by hand in your site, and assigned to the influencer from the dashboard;
  • converting COIN into discount vouchers is not automatic;
  • from the area in your site people can only apply as influencers, and campaign links and levels are not shown yet.
Want a hand with the integration? Write to support@i-creativi.com.
Would you rather we did it? Installation and migration are included.Write to support