From your campaigns, you can create tracked links and share them with the KOLs of your choice. Several useful metrics 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 supported natively. For other CMSs or custom sites, contact your Kolsquare representative or our support team.
Shopify
First step
Go to your Shopify admin
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
ā
āOn the āThemesā page, find your current theme and click its three-dot menu, then on "Edit code"
ā
ā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)
ā
āIn this file, scroll to the bottom and paste the following code (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>Save your changes
Second step
Go to your Shopify admin
Search for "Pixels" in the search bar and click on "Pixels" in the search results
ā
āOnce in the "Pixels" menu (Customer Events), click on "Add custom pixel"
ā
āName the custom pixel āKolsquareā to make it easier to find.
āIn the Customer Privacy section, expand the āPermissionā and āData saleā sections, then select āNot requiredā for the first one, and "Data collected does not qualify as data sale" for the second one.
āIn the "Code" section, delete the existing content and 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'));
});Click āSaveā at the top of the page and confirm if prompted.
āClick "Connect" to activate the pixel.
ā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
Go to your Prestashop admin
Got to "Modules" > "Module Manager"
ā
āOnce on the page, click on "Upload a module" at the top right of the page
ā
āChoose the file "kolsquare.zip" which you can find here
ā
āThe module 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.
Other e-shop and custom e-shop
We will be able to track sales only by sharing tracking links generated in Kolsquare.
campaigns -> tracking links
To let Kolsquare link your campaign with your sales, you need to add two code snippets to your codebase.
To do so, paste the code below so that it runs on the first page load. It must be loaded on every page.
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 function must run when the order is submitted.
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. The only parts you must not change are the data object and the retrieval URL.
Once your setup is done, we will collect the data and add it to your campaign reporting š
Data imported into the application
Sales data is synchronized twice a day to update your reports
Number of sales
Revenue
Average order value
Number of articles
Average number of articles per sale
ROI (Revenue - Invested budget)
ROAS (Revenue / Invested budget)
Conversion rate (Number of sales / Number of clicks)
