{"id":14345,"date":"2016-08-18T07:20:22","date_gmt":"2016-08-18T05:20:22","guid":{"rendered":"https:\/\/helpcenter.blendee.com\/article\/esempio-di-implementazione\/"},"modified":"2024-03-21T10:09:01","modified_gmt":"2024-03-21T09:09:01","slug":"esempio-di-implementazione","status":"publish","type":"article","link":"https:\/\/helpcenter.streamwise.it\/en\/article\/esempio-di-implementazione\/","title":{"rendered":"Implementation Example"},"content":{"rendered":"\n<p>Below is an example of the implementation of tracking scripts within an e-commerce developed with PrestaShop v. 1.6.1.1.<\/p>\n\n<h2 class=\"wp-block-heading\">General Script<\/h2>\n\n<p>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:<\/p>\n\n<pre class=\"wp-block-preformatted\"><!-- Blendee basic code --> <script type=\"text\/javascript\">\nvar _sbnaq = _sbnaq || [];\n_sbnaq.push([\"setDocumentTitle\", document.domain + \"\/\" + document.title]); {if isset($cookie-&gt;id_customer)}\n_sbnaq.push([\"setSiteUserId\", {$cookie-&gt;id_customer}]); {else}\n_sbnaq.push([\"setSiteUserId\", 0]); {\/if}\n_sbnaq.push([\"setSiteId\", 101]); _sbnaq.push([\"setCatalogId\", 9]); _sbnaq.push([\"setLanguage\", \"{$lang_iso}\"]); _sbnaq.push([\"trkPageView\"]);\n(function() {\nvar u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") +\n\":\/\/staging.marketingspray.com\/tracking\/\"; _sbnaq.push([\"setTrackerUrl\", u]);\nvar d=document, g=d.createElement(\"script\"), s=d.getElementsByTagName(\"script\")[0]; g.type=\"text\/javascript\";\ng.defer=true; g.async=true; g.src=u+\"sbn.js\"; s.parentNode.insertBefore(g,s);\n})();\n<\/script>\n<!-- Fine Blendee basic code --><\/pre>\n\n<p>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).<\/p>\n\n<h2 class=\"wp-block-heading\">Category Page Tracking<\/h2>\n\n<p>(Category View)<br\/>In the category.tpl file of the current template we can insert (e.g. at the end of the file):<\/p>\n\n<pre class=\"wp-block-preformatted\"><script>_sbnaq.push([\"trkCategoryView\", {$category->id}]); <\/script><\/pre>\n\n<h2 class=\"wp-block-heading\">Product Page Tracking<\/h2>\n\n<p>(Product View)<br\/>In the product.tpl file of the current template we can insert (e.g. at the end of the file):<\/p>\n\n<pre class=\"wp-block-preformatted\"><script>_sbnaq.push([\"trkProductView\", {$product->id}]); <\/script><\/pre>\n\n<h2 class=\"wp-block-heading\">Purchase Tracking<\/h2>\n\n<p>(Salt)<br\/>If we choose to track the purchase on the order confirmation page, we must act on the file: porder- confirmation.tpl.<br\/>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:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>$idordine: A variable containing the order identifier<\/li>\n\n\n\n<li>$prodlist: A variable containing the list of products that are part of the order itself<\/li>\n\n\n\n<li>$currency: The currency used for the transaction<\/li>\n<\/ul>\n\n<p>There are two steps to be taken:<\/p>\n\n<p>1. In the controllers\/front\/OrderConfirmationController.php file, in the initContent() method, add the following lines of code just before the last line ($this\u2192setTemplate(_PS_THEME_DIR_.&#8217; order-confirmation.tpl&#8217;);):<\/p>\n\n<pre class=\"wp-block-preformatted\">$order = new Order($this-&gt;id_order);\n$prodlist = $order-&gt;getProducts();\n$currency = new Currency($order-&gt;id_currency);\n$this-&gt;context-&gt;smarty-&gt;assign(array( 'adb_prodlist' =&gt; $prodlist, 'adb_idordine' =&gt; $this-&gt;id_order, 'adb_currency' =&gt; $currency-&gt;iso_code, ));\n<\/pre>\n\n<p>2. In the order-confirmation.tpl file, add at the bottom:<\/p>\n\n<pre class=\"wp-block-preformatted\"><script>var adb_ord_id = {$adb_idordine}; var adb_ts = new Date();\nadb_ts = adb_ts.toISOString();\nvar adb_tsarray = adb_ts.split('.');\n{foreach from=$adb_prodlist item=product name=item}\n_sbnaq.push([\"trkProductSale\",adb_ord_id,{$product.id_product},{$product.product _quantity},'',{$product.total_price_tax_excl},{$product.total_price_tax_incl},{$ product.total_shipping_price_tax_incl},'{$adb_currency}',adb_tsarray[0],0,0]);\n{\/foreach} <\/script><\/pre>\n<div class=\"wrap-post-useful post_useful_14345\">\n<p><div style=\"color: black; margin-bottom: 15px;\"><strong>Was this content useful?<\/strong><\/div><\/p>\n<p class=\"post_useful_success post_useful_success_14345\">Thanks for contributing!<\/p>\n<div class=\"post-useful-buttons post_useful_buttons_14345\">\n<a href=\"javascript:;\" style=\"border:0px;\" title=\"Yes\" class=\"post-useful-vote post-useful-vote-yes\" data-id=\"14345\" data-rate=\"1\">Yes<\/a>\n<a href=\"javascript:;\" style=\"border:0px;\" title=\"No\" class=\"post-useful-vote post-useful-vote-no\" data-id=\"14345\" data-rate=\"0\">No<\/a>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":7,"template":"","format":"standard","article-category":[160,161],"article-tag":[165,162],"class_list":["post-14345","article","type-article","status-publish","format-standard","hentry","article-category-getting-started-en","article-category-install-blendee","article-tag-prestashop-en","article-tag-setup-en"],"_links":{"self":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14345"}],"collection":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/types\/article"}],"author":[{"embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":3,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14345\/revisions"}],"predecessor-version":[{"id":14357,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14345\/revisions\/14357"}],"wp:attachment":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/media?parent=14345"}],"wp:term":[{"taxonomy":"article-category","embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article-category?post=14345"},{"taxonomy":"article-tag","embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article-tag?post=14345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}