Install Tracking
Add Drapier scripts to your storefront and publisher site for attribution and analytics.
There are two scripts to install as part of onboarding:
- Attribution script — Goes on the storefront. Captures click IDs and attaches them to orders so commissions are attributed correctly.
- Publisher beacon — Goes on your publisher site. Gives you analytics on which products and pages drive the most affiliate traffic.
Publisher beacon (your site)
The publisher beacon is a lightweight analytics script you add to your own site. It powers the insights dashboard in your publisher portal.
What it tracks
- Popular products — Which affiliate links on your site get the most clicks
- Top pages — Which of your pages drive the most affiliate traffic
- Product discovery — Luxury products your audience links to that aren't in the network yet (visible to admins)
Installation
Add the script to your site's <head> or before </body>:
<script src="https://cdn.drapier.io/beacon.js"
data-publisher-id="YOUR_PUBLISHER_ID"
data-beacon-url="https://api.drapier.io/api/beacon"
async></script>Replace YOUR_PUBLISHER_ID with your publisher ID from the dashboard Settings page.
Privacy
- No cookies are set by this script
- No personally identifiable information is collected
- All data is associated with your publisher ID, not individual visitors
Attribution script (storefront)
The attribution script goes on the brand storefront (Italist, HEWI, Verishop). It captures affiliate click IDs, persists them across the shopping session, and attaches them to orders.
There are two installation methods depending on the storefront platform.
Shopify stores
Drapier Shopify app handles everything automatically via a theme app extension.
Installation
- Go to the Shopify App Store and search "Drapier".
- Click Add app and authorize the requested permissions.
- The attribution script is automatically injected into your theme — no manual Liquid editing required.
- Open the app in Shopify Admin to configure your settings.
The app requests these Shopify API scopes:
| Scope | Purpose |
|---|---|
read_orders | Receive order webhooks for commission attribution |
read_script_tags | Verify attribution script installation |
write_script_tags | Install the attribution tracking snippet |
How it works
- Click capture — When a visitor arrives via an affiliate link (
?icg_click=clk_abc123), the script reads the click ID from the URL. - Persistence — The click ID is stored in a first-party cookie (
_icg_click, 30-day expiry) andlocalStoragefor resilience. - Cart attribution — On every page load and after every
cart/add.jscall, the script writes the click ID as a Shopify cart attribute (_icg_click_id) via the AJAX API. - Order webhook — When the customer checks out, Shopify includes the cart attribute in the order's
note_attributes. Drapier API receives theorders/createwebhook and creates a commission for the matched publisher.
Verify the installation
- Navigate to any page on your store.
- Open DevTools (F12) and go to the Console tab.
- Type
document.cookieand look for_icg_click. - Alternatively, check the Network tab for requests to
cart/update.jscontaining_icg_click_id.
If the script is not present, go to Shopify Admin → Online Store → Themes → Customize and verify Drapier app block is enabled.
Test attribution end-to-end
- Append
?icg_click=test_123to any product URL on your store. - Open DevTools → Application → Cookies and confirm
_icg_clickis set totest_123. - Add the product to your cart.
- Open DevTools → Network → filter for
cart/update.jsand check the request body for_icg_click_id.
For Shopify-specific troubleshooting, see the Shopify Troubleshooting guide.
Non-Shopify stores
For storefronts not on Shopify, add the attribution script manually. The script works on any site that uses Shopify's AJAX cart API (/cart/update.js and /cart/add.js), including headless storefronts backed by Shopify.
Add the script tag
Include the script on every page of your storefront, before the closing </body> tag:
<script src="https://cdn.drapier.io/attribution/icg-attribution.js" defer></script>Alternatively, self-host the script by downloading it and serving it from your own domain.
What the script does
The script runs on every page load and performs the following:
- Checks the URL for an
icg_clickquery parameter. - If found, stores the click ID in:
- A first-party cookie (
_icg_click) with a 30-day expiry,SameSite=Lax,Secure localStorageunder the key_icg_click
- A first-party cookie (
- If no URL parameter, recovers the click ID from the cookie or
localStorage(whichever is available). - Writes the click ID to Shopify cart attributes by POSTing to
/cart/update.js:
{
"attributes": {
"_icg_click_id": "clk_abc123"
}
}- Intercepts
cart/add.jscalls and re-attaches the click ID after each add, ensuring the attribution survives cart modifications.
Configuration
The script uses these constants — they are not configurable and must match Drapier backend:
| Constant | Value | Purpose |
|---|---|---|
| URL parameter | icg_click | Query parameter on inbound affiliate links |
| Cookie name | _icg_click | First-party cookie storing the click ID |
| localStorage key | _icg_click | Backup storage for the click ID |
| Cart attribute | _icg_click_id | Shopify cart attribute key sent with orders |
| Cookie duration | 30 days | Matches the attribution window |
Requirements
- The storefront must use Shopify's AJAX cart API (
/cart/update.jsand/cart/add.js). The script POSTs to these endpoints to attach the click ID as a cart attribute. - If your storefront uses a custom cart implementation that does not use Shopify's AJAX API, contact support for a custom integration.
- The script must run on the same domain as the storefront (first-party context) for the cookie to be set correctly.