inro-shopify-script
v1.0.4
Published
An IIFE script that captures attribution and UTM parameters from the URL, persists them to `localStorage`, and forwards them as Shopify cart attributes so tracking data is available on the order at checkout.
Downloads
408
Readme
Shopify Script
An IIFE script that captures attribution and UTM parameters from the URL, persists them to localStorage, and forwards them as Shopify cart attributes so tracking data is available on the order at checkout.
How it works
- Reads tracking params from the URL —
inro_id,username,utm_medium,utm_source,utm_campaign - Loads any previously stored params from
localStorage(key:tracking_params_v1) - Merges — URL params win over stored ones when both are present
- Persists merged params back to
localStorage(only when new URL params are found) - POSTs to
/cart/update.jswith the params as cartattributes
Installation
Add to the <head> or <body> of your Shopify theme (e.g. theme.liquid):
<script src="https://d2cekbmr7xduo8.cloudfront.net/inro-shopify-script.min.js" defer></script>Tracked parameters
| Parameter | Description |
| -------------- | ----------------------------- |
| inro_id | Inro user/referral identifier |
| username | Inro username |
| utm_medium | UTM medium |
| utm_source | UTM source |
| utm_campaign | UTM campaign |
Development
npm install
npm run dev # start local dev server (opens docs/index.html)
npm run build # build minified output to dist/Known issues & limitations
- No fetch response validation —
/cart/update.jserrors (e.g. 422, 403) are silently ignored; only network-level failures are caught. - No TTL on stored params — once written, params stay in
localStorageindefinitely. A returning visitor with no URL params will still be attributed to their original campaign on every future visit. - Runs on every page load — as long as any params are stored or present in the URL, the script hits
/cart/update.json every page load. Consider usingsessionStorageas a per-session dedup flag if cart update volume is a concern. - Falsy value filtering — values like
"0"or"false"are filtered out by the truthiness check before sending to the cart.
