Below is an example of the implementation of tracking scripts within an e-commerce developed with PrestaShop v. 1.6.1.1.
General Script
One possibility is to insert the main javascript (the one that allows you to activate all Blendee functions) in the header.tpl file of the current theme:
This will make the features of the Blendee platform available on every page. In particular, it will be possible to proceed with the correct tracking of the actions as indicated below (we present only some typical cases; please refer to the complete list of actions already proposed).
Category Page Tracking
(Category View)
In the category.tpl file of the current template we can insert (e.g. at the end of the file):
Product Page Tracking
(Product View)
In the product.tpl file of the current template we can insert (e.g. at the end of the file):
Purchase Tracking
(Salt)
If we choose to track the purchase on the order confirmation page, we must act on the file: porder- confirmation.tpl.
Plotting the order in this case is slightly more complicated, as in this file you need to make some variables available that may not be available in the template:
- $idordine: A variable containing the order identifier
- $prodlist: A variable containing the list of products that are part of the order itself
- $currency: The currency used for the transaction
There are two steps to be taken:
1. In the controllers/front/OrderConfirmationController.php file, in the initContent() method, add the following lines of code just before the last line ($this→setTemplate(_PS_THEME_DIR_.’ order-confirmation.tpl’);):
$order = new Order($this->id_order); $prodlist = $order->getProducts(); $currency = new Currency($order->id_currency); $this->context->smarty->assign(array( 'adb_prodlist' => $prodlist, 'adb_idordine' => $this->id_order, 'adb_currency' => $currency->iso_code, ));
2. In the order-confirmation.tpl file, add at the bottom:
Thanks for contributing!