Magento

This is a guide to manually install Kelkoo Sales Tracking if you use Magento 2 (up to 2.3).

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.

Install the leadtag

If you want to add Kelkoo Sales Tracking leadtag without creating a module, you can add the following code on your active theme.

To add in YourTheme/Magento_Theme/layout/default_head_blocks.xml

HTML
<script src="https://s.kk-resources.com/leadtag.js" src_type="url"/>

Install the Conversion tag

app/code/Kelkoo/Modulekelkoost/   
|- Block   
|    |- Success.php   
|- etc   
|    |- di.xml   
|    |- module.xml   
|- registration.php   
|- view   
|    |- frontend   
|    |     |-  layout   
|    |     |     |- checkout_onepage_success.xml   
|    |     |-  templates   
|    |     |     |- checkout   
|    |     |     |     |- success.phtml 

  • Modify app/code/Kelkoo/Modulekelkoost/view/frontend/templates/checkout/success.phtml to set the correct MerchantId, and to pass the basket and any optional fields

HTML
<?php
/** @var $block \Kelkoo\Modulekelkoost\Block\Success */

$order = $block->getOrder();
$jsonFlags = JSON_HEX_TAG
    | JSON_HEX_AMP
    | JSON_HEX_APOS
    | JSON_HEX_QUOT
    | JSON_THROW_ON_ERROR;
?>

<?php if ($order && $order->getId()): ?>
    <?php
    $basket = [];

    foreach ($order->getAllVisibleItems() as $item) {
        $basket[] = [
            'productname' => (string) $item->getName(),
            'productid' => (string) $item->getSku(),
            'quantity' => (float) $item->getQtyOrdered(),
            'price' => (float) $item->getPrice(),
        ];
    }
    ?>

    <script type="text/javascript">
        window._kkstrack = {
            // Replace these placeholders with your merchant configuration.
            merchantInfo: [{
                merchantId: "YOUR_MERCHANT_ID"
            }],

            // JSON encoding with HEX flags safely embeds dynamic values.
            orderValue: <?= /* @noEscape */ json_encode(
                (float) $order->getGrandTotal(),
                $jsonFlags
            ) ?>,
            orderId: <?= /* @noEscape */ json_encode(
                (string) $order->getId(),
                $jsonFlags
            ) ?>,
            basket: <?= /* @noEscape */ json_encode(
                $basket,
                $jsonFlags
            ) ?>,

            // All fields below are OPTIONAL. Uncomment those you need.
            // Keep a comma between properties when enabling multiple fields.
            // Encode dynamic values with the same JSON flags used above.
            // 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 script = document.createElement('script');
            script.async = true;
            script.src = 'https://s.kk-resources.com/ks.js';
            document.head.appendChild(script);
        })();
    </script>
<?php endif; ?>
  • Enable kelkoost module :

php bin/magento module:enable Kelkoo_Modulekelkoost 
php bin/magento setup:upgrade --keep-generated 

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

Troubleshooting

If conversions are not being tracked correctly, check Troubleshooting Manual Installation — the Magento integration uses the same underlying Lead Tag / Conversion Tag mechanism.