English
Client-side Tracking Script
Introduction
Thanks to the implementation of our conversion tracking script, Click2Buy is able to collect validated sales generated by users coming from our solution.
This tracking enables brands to accurately measure the ROI of the traffic directed to retailer websites via the Click2Buy Where to Buy solution.
To set up the tracking, you will need your Retailer Key, which will be provided by your Click2Buy Retailer Account Manager. This identifier will be used in both available implementation methods.
Two implementation methods are available:
🏷️ Via Google Tag Manager
Recommended — the simplest and fastest method to implement.
💻 Via a native implementation
Direct integration within the website code.
How it works
- A user clicks on a Click2Buy "Where to Buy" button on a brand's website and is redirected to your website. The URL of the page they land on (the landing page) contains a
c2bmparameter, for examplehttps://www.your-site.com/product/123?c2bm=…. - Our script, loaded on that page, stores this value in a first-party cookie on your domain.
- When the user completes an order, our script, loaded on the order confirmation page, sends the sale validation to Click2Buy.
c2bm is the default name of this parameter. Click2Buy can configure another name for your website: in that case, it replaces c2bm everywhere in this guide.
The landing page depends on the product: it can be a product page, a cart page, a search page, etc. This is why the script must be loaded on every page of your website.
If the script is not present on the landing page, our script falls back to an older mechanism based on a third-party cookie, which is blocked by a growing number of browsers. Sales from these browsers are then not attributed.
Requirements
Before you start
- All pages: the script must be loaded on every page of your website, including the order confirmation page.
- Consent: the script must only be loaded after the user has given consent, in the audience measurement / analytics category (not advertising). The script does not detect consent itself: loading it is up to your consent management platform (CMP) or your tag manager.
- URL parameters: if your website redirects users as soon as they arrive (short URLs, language or country selection, URL normalization…), query parameters must be kept during the redirect. Otherwise the
c2bmparameter is lost.
Consent given on the landing page
If the user accepts cookies on the landing page itself, the script must be loaded right away on that page, not only on the next page: the c2bm parameter is only present in the URL of the landing page.
Implementation via Google Tag Manager
We have developed an official Google Tag Manager template that allows for easy implementation of Click2Buy conversion tracking. This template enables retailers to configure tracking without needing to write any custom code. To install the tag, simply refer to our GitHub documentation, which includes:
- detailed installation instructions
- the template file to import into Google Tag Manager
- the steps required to configure the tag: one tag to load the script on all pages, and one tag to send the order on your purchase event
During the tag configuration, you will only need to enter your Retailer Key, which will be provided by your Click2Buy contact.
👉 All documentation and required files are available here: https://github.com/Click2Buy/gtm-web-template
Native Implementation (in your website code)
The implementation is done in two steps: load the script on all pages (step 1), then declare the sale on the order confirmation page (step 2).
Step 1: load the script on all pages
Add the following code to every page of your website, including the order confirmation page, once the user has given consent:
html
<!-- Click2Buy retailer script -->
<script async src="https://rs.clic2buy.com/retailers/YOUR_RETAILER_KEY.js"></script>YOUR_RETAILER_KEY must be replaced by your Retailer Key, provided by your Click2Buy contact.
The async attribute ensures the script does not block the display of your pages.
Step 2: declare the sale on the order confirmation page
Add the following code only on the order confirmation page, in addition to step 1:
html
<!-- Click2Buy validation -->
<script>
window.C2B = window.C2B || {}; C2B.q = C2B.q || [];
C2B.validationProcess = C2B.validationProcess || function () { C2B.q.push(arguments) };
C2B.validationProcess(ORDER_PARAMETERS);
</script>ORDER_PARAMETERS must be replaced by the order's information according to the format just below (or according to your datalayer).
The first two lines make the call independent of the loading order: it works even if it runs before the script of step 1 is loaded.
Already using our previous snippet?
If you already integrated our script with the previous snippet ((function(i,s,o,g,r,a,m){…})(…,'C2B')) on your order confirmation page, you can keep it as is: it is still supported. You only need to add step 1 on all the other pages of your website.
If the script ends up loaded several times on the same page (for example via this snippet and via Google Tag Manager), only the first load is taken into account: the sale is not counted twice.
Parameters of the C2B.validationProcess function
The function must receive as a parameter an object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
totalAmount | Number | Required | Total amount of the basket. |
currency | String | Required | Currency code (ISO 4217, e.g. "EUR"). |
products | Array | Required | An array of product objects (see below). |
Fields of product objects
| Field | Type | Required | Description |
|---|---|---|---|
ean | String | Required* | EAN-13 code of the product. |
upc | String | Optional | UPC code of the product. |
retailerReference | String | Required* | Internal reference/SKU used by the retailer. |
amount | Number | Required | Unit price of the product. |
quantity | Number | Required | Quantity purchased. |
name | String | Required | Name of the product. |
brand | String | Required | Brand name of the product. |
manufacturerReference | String | Optional | Manufacturer's reference. |
packaging | String | Optional | Product packaging details. |
metadata | JSON | Optional | Any other useful data (free structure). |
Filling in the fields
* Product identification: we need at least the product's EAN or UPC code to identify it. If you do not have this information, you can send us your internal reference (retailerReference) instead.
Missing fields: if you can't provide some fields, you can leave them empty. If your configuration requires a value for every field, you can send null as the default value.
WARNING
When copying and pasting the script into certain text editors, quotation marks (" ") may be automatically modified. Please ensure they are correctly formatted to avoid any errors in the script execution.
Content Security Policy
If your website uses a Content Security Policy (CSP), add the following domains to it. All three are required:
| Directive | Domain | Used for |
|---|---|---|
script-src | rs.clic2buy.com | Loading the tracking script |
frame-src | t.clic2buy.com | Reading our third-party cookie, used as a fallback when the script was not loaded on the landing page |
connect-src | analytics.clic2buy.com | Sending the sale validation |
For example, with these domains added to your existing directives:
http
Content-Security-Policy: script-src 'self' rs.clic2buy.com; frame-src 'self' t.clic2buy.com; connect-src 'self' analytics.clic2buy.com;You can also allow *.clic2buy.com in these directives, which covers all three domains.
Cookies
The script only stores data on the user's device when Click2Buy has enabled first-party tracking for your website, after checking that the script is loaded after consent. It only uses first-party cookies with a limited lifetime, deleted automatically by the browser when they expire. They must be declared in your consent management platform (CMP), in the audience measurement / analytics category:
| Cookie | Content | Duration |
|---|---|---|
_c2b_attr | Identifier of the Click2Buy click, received in the c2bm parameter of the landing page | 30 days |
_c2b_sent_<id> | Marker preventing the same sale from being sent twice (page reload) | 30 minutes |
Declare _c2b_* in your CMP
Some CMPs (CookieScript, for example) delete every cookie that is not declared in their cookie list, on each page load, even when the user accepts all cookies. If our cookies are not declared, _c2b_attr is deleted and sales are not attributed.
Declare the pattern _c2b_* (or the regular expression _c2b.*, depending on your CMP) rather than each name: it covers _c2b_sent_<id>, whose name changes with each sale, and the cookies set by debug mode.
The script does not use localStorage or sessionStorage.
In the fallback mode, the script reads the validation-<retailer key> third-party cookie set by Click2Buy on the clic2buy.com domain when the user clicked on the brand's website.
Attribution rules
- Attribution window: a sale is attributed to Click2Buy if it happens within 30 days after the click.
- Last click: a new click on a Click2Buy button replaces the previous one. A visit from another channel (newsletter, ads…) does not remove the Click2Buy attribution.
- Repeat orders: every order placed within the attribution window is attributed to the same click.
- Duplicates: a sale is only sent once per order confirmation page every 30 minutes (page reload, back button).
Data and privacy
Our tag only collects the contents of orders from users redirected by Click2Buy. No personal data is collected.
The cookies used by the script are described in the Cookies section above.
Click2Buy complies with the GDPR. For any question about data protection, you can contact our Data Protection Officer (DPO):
- Artaches Kherounts
- 📧 dpo@click2buy.com
- 📞 +33 3 66 72 29 04