Campaign attribution
When a contact clicks a link in one of your Sender.net campaigns, the link includes parameters that identify the contact and the campaign. The JavaScript SDK saves these on the visitor’s device, so that later visits, carts and orders on your website are credited to that contact and campaign.
The SDK stores attribution data in two places:
| Name | Type | Contents | Duration |
|---|---|---|---|
sender_subscriber_id | Cookie | The contact’s ID | 30 days |
sender_ecommerce_params | Local storage | The contact’s ID, campaign ID and campaign type | No expiry; removed when an order is completed |
On Shopify stores, the SDK also adds the campaign parameters to the cart.
See Cookies and local storage for everything else the SDK stores.
Disable attribution
Section titled “Disable attribution”If your website needs consent before storing marketing data, you can start the SDK with attribution turned off. Pass { disableAttribution: true } as the second argument of the sender() call in your snippet:
<script> (function (s, e, n, d, er) { s['Sender'] = er; s[er] = s[er] || function () { (s[er].q = s[er].q || []).push(arguments) }, s[er].l = 1 * new Date(); s[er].on = function(event, callback) { s[er].listeners = s[er].listeners || {}; (s[er].listeners[event] = s[er].listeners[event] || []).push(callback); }; var a = e.createElement(n), m = e.getElementsByTagName(n)[0]; a.async = 1; a.src = d; m.parentNode.insertBefore(a, m) })(window, document, 'script', 'https://cdn.sender.net/accounts_resources/universal.js', 'sender'); sender('YOUR_ACCOUNT_PUBLIC_ID', { disableAttribution: true });</script>While attribution is disabled, the SDK:
- doesn’t set the
sender_subscriber_idcookie or savesender_ecommerce_params, - removes both if they were saved on an earlier visit,
- doesn’t add campaign parameters to the Shopify cart.
Forms and popups work as usual.
Enable attribution after consent
Section titled “Enable attribution after consent”Once the visitor agrees to marketing cookies, turn attribution on:
sender('enableAttribution');You can call it at any time, even before the SDK has finished loading. After the SDK has loaded, sender.enableAttribution() works too.
When enabled, the SDK saves the campaign parameters from the current page’s URL. If the visitor gives consent on a later page, the campaign from the page they first landed on can’t be recovered.
For example, with a consent banner that tells you whether the visitor has already agreed and notifies you when they do:
// In your snippet: start with attribution off unless the visitor already agreedsender('YOUR_ACCOUNT_PUBLIC_ID', { disableAttribution: !yourConsentBanner.hasMarketingConsent()});
// When the visitor accepts marketing cookiesyourConsentBanner.onAccept(() => { sender('enableAttribution');});Replace yourConsentBanner with the API of your consent management platform.
Disable attribution again
Section titled “Disable attribution again”If the visitor withdraws consent, turn attribution off:
sender('disableAttribution');This stops attribution for the rest of the page and removes the stored sender_subscriber_id cookie and sender_ecommerce_params data. On later pages, keep passing { disableAttribution: true } in your snippet while the visitor hasn’t given consent.