Skip to main content

💲 Track your e-commerce sales with tracked links

You have the possibility from your campaigns to create tracked links and share them with the KOLs of your choice. Several useful data can then be retrieved:

  • Number of clicks

  • Sources of clicks

    • Geographic (Country/City)

    • Social networks

You can now track sales on your e-commerce site from these links generated in the application. Shopify and Prestashop are natively supported, do not hesitate to contact your Kolsquare contact or our support in order to best support you on other CMS or custom sites.

Shopify

First step

  1. Go to your Shopify admin

  2. Go to the "Themes" tab of your online store from the left menu, or go directly to this link: https://admin.shopify.com/store/kolshopp/themes
    ​
    ​

  3. Once in the "Theme" page, identify your current Theme and click on the corresponding 3 dots, then on "Edit code"
    ​
    ​

  4. Look for the "theme.liquid" file. You will find it more easily thanks to the search bar at the top left, then click on it (the file will open on the right panel)
    ​
    ​

  5. In this file, go to the very bottom of it and paste the following code there (Be careful not to delete the existing code):
    ​WARNING: Paste the code just before the </body> and </html> tags as in the following screenshot
    ​

    <script>
    if (window) {const urlParams = new URLSearchParams(window?.location?.search);
    const sales_token = urlParams.get('ts');
    if (sales_token) {window.localStorage.setItem('kolsquare', JSON.stringify({ sales_token }));}}
    </script>
  6. Save your modification

Second step

  1. Go to your Shopify admin

  2. Search for "Pixels" in the search bar and click on "Pixels" in the search results
    ​
    ​

    Capture d’écran 2024-10-14 à 17.11.37.png
  3. Once in the "Pixels" menu (Customer Events), click on "Add custom pixel"
    ​
    ​

    Capture d’écran 2024-10-14 à 17.11.52.png
  4. Name the custom pixel “Kolsquare” to make it easier to find.
    ​

    Capture d’écran 2024-10-14 à 17.12.13.png
  5. In the Customer Privacy section, unfold the two banners "Permission" and "Data sale". And select "Not required" for the first one, and "Data collected does not qualify as data sale" for the second one.
    ​
    ​

  6. In the "Code" section, delete the content already present, and copy-paste the following code:
    ​
    ​

    function getCoupons(checkout) {
    const allDiscountCodes = checkout.discountApplications.map((discount) => {
    if (discount.type === 'DISCOUNT_CODE') {
    return discount.title;
    }
    });

    return allDiscountCodes.join(", ");
    }

    analytics.subscribe('checkout_completed', (event) => {
    const { sales_token } = JSON.parse(window.localStorage.getItem('kolsquare'));

    if (!sales_token) return null;

    const checkoutTracking = async data => {
    if (!sales_token) return null;
    const response = await
    fetch(`https://api.kolsquare.com/influence/tracking_links/sales/${sales_token}`, {
    method: 'POST',
    body: JSON.stringify({ tracking_link_sale: {
    order_id: event.data.checkout.order?.id,
    total_price: event.data.checkout.totalPrice.amount,
    currency: event.data.checkout.totalPrice.currencyCode,
    items_count: event.data.checkout.lineItems.length,
    created_at: event.timestamp,
    discount_code: getCoupons(event.data.checkout),
    store_framework: 'shopify_pixel'
    }}),
    headers: {
    'Content-type': 'application/json',
    'Access-Control-Allow-Origin': '*',
    },
    })
    return response;
    }

    checkoutTracking(event).then(() =>
    window.localStorage.removeItem('kolsquare'));
    });
    Capture d’écran 2024-10-14 à 17.14.00.png
  7. Save via the button at the top of the page. And confirm the save if necessary.
    ​
    ​

  8. Click "Connect" to put the pixel online
    ​
    ​

  9. The pixel is installed!

From now on, when a person places an order from a tracked link generated from Kolsquare, the sales information will be visible in the "Reporting" tab of your campaign.

Prestashop

  1. Go to youre Prestashop admin

  2. Got to the "Modules" > "Module Manager"
    ​
    ​

    Capture d’écran 2023-10-20 à 11.13.03.png
  3. Once on the page, click on "Upload a module" at the top right of the page
    ​
    ​

    Capture d’écran 2023-10-20 à 11.13.21.png
  4. Capture d’écran 2023-10-20 à 11.13.29.png
  5. The module is installed!
    ​

    Capture d’écran 2023-10-20 à 11.15.48.png

From now on, when a person places an order from a tracked link generated from Kolsquare, the sales information will be visible in the "Reporting" tab of your campaign.

Other e-shop and custom e-shop

We will able to track sales only by sharing tracking links generated in influence.

campaigns -> tracking links

To leave Kolsquare link your campaign with your sales, you have to put 2 codes’s chunk in
your code base.

To do so, paste the code below at the right place to load the script in first load. (Each page should be
able to load the script)

const urlParams = new URLSearchParams(window.location.search);

const sales_token = urlParams.get('ts');

if (sales_token) {
window.localStorage.setItem('kolsquare', JSON.stringify({ sales_token }));
}

Then add the code below to your checkout page. (The submission must trigger the function).

const kolsquare_tracking_sales = async () => {
const { sales_token } = JSON.parse(window.localStorage.getItem('kolsquare'));
const data = {
order_id: // put your order_id,
order_number: // put your order_number,
total_price: // put your total_price,
currency: // put your currency,
items_count: // put your items_count,
created_at: // put your created_at,
discount_code: // put your discount_code,
}

if (!sales_token) return null;

return await fetch(`https://api.kolsquare.com/influence/tracking_links/sales/${sales_token}`, {
method: 'POST',
body: JSON.stringify({ tracking_link_sale: data }),
headers: {
'Content-type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
'Cache-Control': 'no-cache',
})
}

kolsquare_tracking_sales().then(() => window.localStorage.removeItem('kolsquare'));

The code is written as an example. You can modify it as you wish. Only the data object and
retrieval url cannot be modified.

Once your setup is done, we will catch the data et put it in your campaign reporting 🎉

The data that will be uploaded in the application

Sales data is synchronized twice a day to update your reports

  • Number of sales

  • Revenue

  • Average basket

  • Number or articles

  • Average number of articles per sale

  • ROI (Revenue - Invested budget)

  • ROAS (Revenue / Invested budget)

  • Conversion rate (Number of sales / Number of clicks)

Did this answer your question?