How do I configure my module ?

 How do I configure my module

 ?

Configuration of "PREREQUISITES" tab

Detect the modification of your theme's template files to improve the analytics code:

IMPORTANT NOTE:  This section below may appears too much technical for you, in this case, we highly recommend you to see it with your technical contact as well as you inform them in order to take the best decision as possible.

This detection is done on 3 template files: product-list.tpl / products-comparison.tpl / product.tpl

First, let's explain it to you how PrestaShop works around the page that display products list.

Either PS 1.5 or 1.6, all the front-office pages displaying products list should process the product-list.tpl template of your current theme, and in the most cases, it is included in anothers templates, except for the category pages.

By using this template, PrestaShop assigns the "products" variable name into the smarty object, and it is reachable to all the hooks executed in the current page.

So, it lets our module to identify all the products assigned in the current page, and we process them via the "footer" hook, finally in this way, it's no more very important to modify your template as well.

If you have a doubt, this explanation allows you to simply return product clicks action in Google analytics as well as you'll see the product detail.

By a simple check on the products list pages, open the HTML source code, and look for the JavaScript function named "BTGA.productClick()". If you find one at least, it means we could retrieve the products list assigned by PrestaShop controller.

Now for some reasons (CORE modified or overrides done), you still have a doubt, we recommend you to  follow carefully the next chapter below:

Your theme's folder:

shop_root_directory/themes/technical_theme_name/product-list.tpl

"Templates PS 1.5"

"Templates PS 1.6"

"Templates PS 1.7" => You don't need to do anything for PS 1.7 as well as the default theme already includes the "data-product-id" tag into the "themes/classic/templates/catalog/_partials/miniatures/" in the product.tpl file

 

How to modify 3 template files for PS 1.5 : 

NOTE IMPORTANTE: The attribute"data-product-id" is used from the module's version 1.0.3, so for the past versions, you must follow the procedure below by using the "data-id-product" attribute's writing.

1/ Template: product-list.tpl

Original template file of the PS 1.5 theme

{if isset($products)} 
<!-- Products list -->
<ul id="product_list" class="clear">
{foreach from=$products item=product name=products}
<li class="ajax_block_product
{if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if}
{if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix">

And this is the way to add the HTML attribute "data-product-id":

{if isset($products)} 
<!-- Products list -->
<ul id="product_list" class="clear">
{foreach from=$products item=product name=products}
<li class="ajax_block_product
{if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if}
{if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix" data-product-id="{$product.id_product|intval}">

 

2/ Template: product.tpl

Original template file of the PS 1.5 theme

<div class="block_content">
<ul>
{foreach from=$accessories item=accessory name=accessories_list}
{if ($accessory.allow_oosp || $accessory.quantity_all_versions > 0 || $accessory.quantity > 0) AND $accessory.available_for_order
AND !isset($restricted_country_mode)}
{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}
<li class="ajax_block_product{if $smarty.foreach.accessories_list.first} first_item{elseif $smarty.foreach.accessories_list.last} last_item
{else} item{/if} product_accessories_description">

And this is the way to add the HTML attribute "data-product-id":

<div class="block_content">
<ul>
{foreach from=$accessories item=accessory name=accessories_list}
{if ($accessory.allow_oosp || $accessory.quantity_all_versions > 0 || $accessory.quantity > 0) AND $accessory.available_for_order
AND !isset($restricted_country_mode)}
{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}
<li class="ajax_block_product{if $smarty.foreach.accessories_list.first} first_item
{elseif $smarty.foreach.accessories_list.last} last_item{else} item{/if} product_accessories_description" data-product-id="{$accessory.id_product|intval}">

3/ Template: products-comparison.tpl

Original template file of the PS 1.5 theme

{foreach from=$products item=product name=for_products}
{assign var='replace_id' value=$product->id|cat:'|'} <td width="{$width}%" class="ajax_block_product comparison_infos">

And this is the way to add the HTML attribute "data-product-id":

{foreach from=$products item=product name=for_products}
{assign var='replace_id' value=$product->id|cat:'|'} <td width="{$width}%" class="ajax_block_product comparison_infos" data-product-id="{$product->id|intval}">

 

How to modify 3 template files for PS 1.6 : 

1/ Template: product-list.tpl

Original template file of the PS 1.6 theme

 <!-- Products list --> 
<ul{if isset($id) && $id} id="{$id}"{/if} class="product_list grid row{if isset($class) && $class} {$class}{/if}">
{foreach from=$products item=product name=products} {math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo}
{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet}
{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile}
{if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
{if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if}
{if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if}
<li class="ajax_block_product{if $page_name == 'index' || $page_name == 'product'} col-xs-12 col-sm-4 col-md-3{else} col-xs-12 col-sm-6 col-md-4{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if}
{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line
{elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line
{elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if}
{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line{/if}">

And this is the way to add the HTML attribute "data-product-id":

<!-- Products list --> 
<ul{if isset($id) && $id} id="{$id}"{/if} class="product_list grid row{if isset($class) && $class} {$class}{/if}">
{foreach from=$products item=product name=products}
{math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo}
{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet}
{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile}
{if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
{if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if}
{if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if}
<li class="ajax_block_product{if $page_name == 'index' || $page_name == 'product'} col-xs-12 col-sm-4 col-md-3{else} col-xs-12 col-sm-6 col-md-4{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if}
{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line
{elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if}
{if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line
{elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if}
{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line{/if}" data-product-id="{$product.id_product|intval}">

 

2/ Template : product.tpl

Original template file of the PS 1.6 theme

<div class="block_content">
<ul id="bxslider" class="bxslider clearfix">
{foreach from=$accessories item=accessory name=accessories_list}
{if ($accessory.allow_oosp || $accessory.quantity_all_versions > 0 || $accessory.quantity > 0) && $accessory.available_for_order
&& !isset($restricted_country_mode)}
{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}
<li class="item product-box ajax_block_product{if $smarty.foreach.accessories_list.first} first_item
{elseif $smarty.foreach.accessories_list.last} last_item{else} item{/if} product_accessories_description">

And this is the way to add the HTML attribute "data-product-id":

<div class="block_content">
<ul id="bxslider" class="bxslider clearfix">
{foreach from=$accessories item=accessory name=accessories_list}
{if ($accessory.allow_oosp || $accessory.quantity_all_versions > 0 || $accessory.quantity > 0) && $accessory.available_for_order
&& !isset($restricted_country_mode)}
{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}
<li class="item product-box ajax_block_product{if $smarty.foreach.accessories_list.first} first_item
{elseif $smarty.foreach.accessories_list.last} last_item{else} item{/if} product_accessories_description" data-product-id="{$accessory.id_product|intval}">

 

3/ Template : products-comparison.tpl

 Original template file of the PS 1.6 theme

{foreach from=$products item=product name=for_products}
{assign var='replace_id' value=$product->id|cat:'|'}
<td class="ajax_block_product comparison_infos product-block product-{$product->id}">

And this is the way to add the HTML attribute "data-product-id":

{foreach from=$products item=product name=for_products}
{assign var='replace_id' value=$product->id|cat:'|'}
<td class="ajax_block_product comparison_infos product-block product-{$product->id}" data-product-id="{$product->id|intval}">

  

Configuration fo the "Basics settings"  tab

First of all, you must create your Google Analytics account, and configure it as explained in this FAQ: http://faq.businesstech.fr/faq.php?id=121

In this way, you'll get your UA code that should be filled out like this below:

Next, around the "advanced parameters", you can follow a second FAQ on this topic: http://faq.businesstech.fr/faq.php?id=120

The related advanced options are the one shown above. 

Configuration of the "Advanced settings" tab

In this tab, you can select different order statuses considered as "refund".

By default, the module selects the good matching native statuses but you also can have different cases from external modules that define their own "refund" status, you should select it too.

If you have forgotten some statuses as refund one, data won't be returned in the Google analytics interface.

 

 

 

 

Other FAQs in this category