Prestashop

This is a guide to manually install Kelkoo Sales Tracking if you use Prestashop 8 and newer.

You need to edit part of your code to succeed with this implementation.

Before setting up your Kelkoo Sales Tracking Tag

Get your merchantId

See How To get your merchantId

Remove Previous Installations

If your website already includes an older version of Kelkoo Sales Tracking, remove it before installing the tags below. See Remove Previous Installations of Kelkoo Sales Tracking for what to look for and why this matters.

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/YOUR_THEME/templates/_partials/head.tpl (where custom is the name of your template, the default being "prestashop")

  • Add

HTML
  <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:

PHP
 $this->context->smarty->assign([
     'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($this->order),
     'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($this->order),
     'order' => (new OrderPresenter())->present($this->order),
     'order_customer' => $this->objectPresenter->present($this->customer),
     'registered_customer_exists' => Customer::customerExists($this->customer->email, false, true),
 ]);

  • With:

PHP
/* 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'],
  'quantity'=>$product['product_quantity'],
  'price'=>$product['unit_price_tax_incl']);
   array_push($productsKelkoo,$productKelkoo);
}
$this->context->smarty->assign([
  'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($this->order),
  'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($this->order),
  'products_json' => json_encode($productsKelkoo),
  'sales' => $order->getOrdersTotalPaid(),
  'orderid' => $this->id_order,
  'order' => (new OrderPresenter())->present($this->order),
  'order_customer' => $this->objectPresenter->present($this->customer),
  'registered_customer_exists' => Customer::customerExists($this->customer->email, false,
  true),
]);
/* end Kelkoo Sales Tracking*/

  • Go to directory /themes/YOUR_THEME/templates/checkout/_partials/order-confirmation-table.tpl

  • Add at the bottom the file

NOTE: you need to edit the placeholder values in the code below

JavaScript
<script type="text/javascript">
    window._kkstrack = {
    merchantInfo: [{merchantId:"MERCHANTID_VALUE" }],
      orderValue: '{$sales}',
      orderId: '{$orderid}',
      basket: {$products_json nofilter},

      // All the fields below are OPTIONAL. We strongly recommend filling in as many as
      // you can (see "Optional fields" below) — simply remove any line you cannot fill.
      // coupon: 'COUPON_CODE',
      // returningUser: 'RETURNING_USER',
      // currency: 'CURRENCY',
      // vatAmount: 'VAT_AMOUNT',
      // shippingCost: 'SHIPPING_COST',
      // affiliation: 'AFFILIATION',
      // discountAmount: 'DISCOUNT_AMOUNT',
      // paymentStatus: 'PAYMENT_STATUS',
      // customerLifetimeValue: 'CUSTOMER_LIFETIME_VALUE'
    };
    (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>

We recommend assigning _kkstrack on window explicitly (window._kkstrack = {...}, as above) rather than as a bare global, to avoid conflicts if this script runs inside another scope. SeeAdd Basket Information to Kelkoo Sales Tracking for the full basket format and canonical field names.

  • If you have a /themes/YOUR_THEME/templates/checkout/_partials/order-confirmation-table-simple.tpl file you also need to update it with same previous code (express checkout).

Optional fields

None of the fields commented out in the code sample above are required for Kelkoo Sales Tracking to work — a sale will still be tracked without them. We strongly encourage you to populate as many as you can, since they directly improve how we optimise your campaigns. For why each field matters, see Why these optional fields matter.

Running several campaigns, in several countries, or on several websites?

If you run several campaigns with Kelkoo, you only need to install once, using any of the Merchant IDs available in the merchantInfo array above. Kelkoo matches each sale to the right campaign regardless of which Merchant ID you send, so nothing is missed by using just one.

If you operate more than one website, install Kelkoo Sales Tracking separately on each one, using a Merchant ID that belongs to that website. acme.com and acme.fr are the same website for Kelkoo; acme.com and safe.com are two different websites.

Kelkoo Sales Tracking relies on two tags with different consent requirements — the Lead Tag must be gated behind user consent, while the Conversion Tag should not be blocked by a missing consent signal, or your sales will be under-reported.

See Configuring Consent Management (CMP) for full setup and verification instructions.

Test your integration

Please check Test your Kelkoo Sales Tracking setup