Skip to main content
DrapierDrapier

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:

  1. Attribution script — Goes on the storefront. Captures click IDs and attaches them to orders so commissions are attributed correctly.
  2. 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

  1. Go to the Shopify App Store and search "Drapier".
  2. Click Add app and authorize the requested permissions.
  3. The attribution script is automatically injected into your theme — no manual Liquid editing required.
  4. Open the app in Shopify Admin to configure your settings.

The app requests these Shopify API scopes:

ScopePurpose
read_ordersReceive order webhooks for commission attribution
read_script_tagsVerify attribution script installation
write_script_tagsInstall the attribution tracking snippet

How it works

  1. Click capture — When a visitor arrives via an affiliate link (?icg_click=clk_abc123), the script reads the click ID from the URL.
  2. Persistence — The click ID is stored in a first-party cookie (_icg_click, 30-day expiry) and localStorage for resilience.
  3. Cart attribution — On every page load and after every cart/add.js call, the script writes the click ID as a Shopify cart attribute (_icg_click_id) via the AJAX API.
  4. Order webhook — When the customer checks out, Shopify includes the cart attribute in the order's note_attributes. Drapier API receives the orders/create webhook and creates a commission for the matched publisher.

Verify the installation

  1. Navigate to any page on your store.
  2. Open DevTools (F12) and go to the Console tab.
  3. Type document.cookie and look for _icg_click.
  4. Alternatively, check the Network tab for requests to cart/update.js containing _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

  1. Append ?icg_click=test_123 to any product URL on your store.
  2. Open DevTools → ApplicationCookies and confirm _icg_click is set to test_123.
  3. Add the product to your cart.
  4. Open DevTools → Network → filter for cart/update.js and 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:

  1. Checks the URL for an icg_click query parameter.
  2. If found, stores the click ID in:
    • A first-party cookie (_icg_click) with a 30-day expiry, SameSite=Lax, Secure
    • localStorage under the key _icg_click
  3. If no URL parameter, recovers the click ID from the cookie or localStorage (whichever is available).
  4. Writes the click ID to Shopify cart attributes by POSTing to /cart/update.js:
{
  "attributes": {
    "_icg_click_id": "clk_abc123"
  }
}
  1. Intercepts cart/add.js calls 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:

ConstantValuePurpose
URL parametericg_clickQuery parameter on inbound affiliate links
Cookie name_icg_clickFirst-party cookie storing the click ID
localStorage key_icg_clickBackup storage for the click ID
Cart attribute_icg_click_idShopify cart attribute key sent with orders
Cookie duration30 daysMatches the attribution window

Requirements

  • The storefront must use Shopify's AJAX cart API (/cart/update.js and /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.

On this page