This is a guide to manually install Kelkoo Sales Tracking if you use Prestashop 1.7 and newer (tested with Prestashop 1.7.8.2)
You need to edit part of your code to succeed with this implementation.
Before setting up your Kelkoo Sales Tracking Tag
Get your merchantId and associated Country Code
See How To get your merchantId and associated Country Code
Clean any old version of Kelkoo Sales Tracking
-
In your code, remove any Kelkoo Sales tracking tag (search for leadtag.js and _kkstrack)
-
On your website backend, uninstall any Kelkoo Sales Tracking plugin you might have installed
Backup your files
Before doing any changes, please remember to back up the files you’re going to modify.
Check Recompile option
-
Go to Advanced parameters -> Performance
-
Make sure that “Recompile templates if files have been updated ” is selected for Template compilation.
Install the leadtag
-
Open themes//templates/_partials/head.tpl (where custom is the name of your template, the default being “prestashop”)
-
Add
<script async="true" type="text/javascript" src="https://s.kk-resources.com/leadtag.js" ></script>
-
Clear you cache by going to Admin > Advanced Paramaters > Performance > Clear Cache
Install the Conversion tag
-
Open the file /controllers/front/OrderConfirmationController.php
-
Replace following code block:
this->context->smarty->assign(array(
'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order),
'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order),
'order' => $presentedOrder,
'register_form' => $register_form,
));
-
With:
/* Kelkoo Sales Tracking */
$order = new Order($this->id_order);
$products = $order->getProducts();
$productsKelkoo=array();
foreach ($products as $product) {
$productKelkoo=array('productname'=>$product['product_name'],
'productid'=>$product['product_reference'],
'svn1'=>$product['product_quantity'],
'svn2'=>$product['unit_price_tax_incl']);
array_push($productsKelkoo,$productKelkoo);
}
$this->context->smarty->assign(array(
'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order),
'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order),
'products_json' => json_encode($productsKelkoo),
'sales' => $order->getOrdersTotalPaid(),
'orderid' => $this->id_order,
'order' => $presentedOrder,
'register_form' => $register_form,
));
/* end Kelkoo Sales Tracking*/
-
Go to directory /themes//templates/checkout/_partials/order-confirmation-table.tpl
-
Add at the bottom the file
<script type="text/javascript">
_kkstrack = {
merchantInfo: [{ country:"COUNTRY", merchantId:"MERCHANTID_VALUE" }],
orderValue: '{$sales}',
orderId: '{$orderid}',
basket: {$products_json nofilter}
};
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://s.kk-resources.com/ks.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})();
</script>
-
If you have a /themes//templates/checkout/_partials/order-confirmation-table-simple.tpl file you also need to update it with same previous code (express checkout).
Customize Conversion tag code
You need to edit some elements of the Conversion Tag
Those values can be hardcoded as they are the same for all the sales registered.
-
MERCHANTID_VALUE: This is the unique ID representing your shop within the Kelkoo Group system.
-
Check How To get your merchantId and associated Country Code.
-
If you have multiple MerchantId please check If you have multiple merchantIds and countries
-
-
COUNTRY is the 2-letter country code (lower case) for the country on which your products are listed on Kelkoo Group. Check Full list of Kelkoo Group country codes.
If you have multiple merchantIds and countries
If you have several Kelkoo Group campaigns running for the same website (multiple MerchantId), you can setup all campaigns within the same tag.
You just need to have the following structure for the merchantInfo variable:
merchantInfo : [
{
country:'fr',
merchantId:'12941513'
},
{
country:'uk',
merchantId:'56789'
}
]
-
Clear you cache by going to Admin > Advanced Paramaters > Performance > Clear Cache
Test your integration
Please check Test Integration
If you face issues
Please check Common Issues with Prestashop Integration before contacting the support.