mnmak Posted January 29, 2015 Share Posted January 29, 2015 Hi there, I'm trying to figure it out where to place the google adwords code tracking the sales. Should I put it in paypal's validation.tpl, order-confirmation.tpl, order-summary.tpl or elsewhere? I already placed it in /my theme/order-confirmation.tpl , but it doesnt seem to work. Which template corresponds to the page where the customer ends up after finishing the order? I have the default setup, where the returning options in the paypal account are turned off. The url of the page where you end up when paid is something like: /module/paypal/submit?key=4931333734c007b33cc1002f0cb7f60f&id_module=192&id_cart=189&id_order=82 - it is odd, because the paypal is in folder "modules", not "module". Any help will be much appreciated. Prestashop is 1.6.0.11, paypal module is Europe v3.8.1 . Thanks in advance Link to comment Share on other sites More sharing options...
nematodesdirect Posted May 9, 2015 Share Posted May 9, 2015 Hi, Did you get this sorted in the end, if not below is how I managed to get it to work (its a bit of a bodge job but it was very easy and worked a treat on my PrestaShop™ 1.5.2.0) Ensure you have the Prestashop Google Analytics Module installed (my version was - Version : 1.8.1) Now Find the following file: /modules/ganalytics/views/templates/hook/header.tpl Open the header.tpl file in your preferred editor (see appendix 1 below for a view of my file before it was edited) Login to your adwords account and generate your custom conversion tracking code. Paste your Adwords conversion code at the bottom below the closing analytics script tag. (See my example - appendix 2) Change this parameter within your adwords conversion tracking code: var google_conversion_value = {$trans.total}; Save and push the file live Do a test transaction to make sure you haven't made a fatal error Watch the data appear in your adwords account (It takes about an hour from when your first order was placed. Hope that helps (Please note: im a bodger, not a developer) Appendix 1 {** 2007-2014 PrestaShop** NOTICE OF LICENSE** This source file is subject to the Academic Free License (AFL 3.0)* that is bundled with this package in the file LICENSE.txt.* It is also available through the world-wide-web at this URL:* http://opensource.org/licenses/afl-3.0.php* If you did not receive a copy of the license and are unable to* obtain it through the world-wide-web, please send an email* to [email protected] so we can send you a copy immediately.** DISCLAIMER** Do not edit or add to this file if you wish to upgrade PrestaShop to newer* versions in the future. If you wish to customize PrestaShop for your* needs please refer to http://www.prestashop.com for more information.** @author PrestaShop SA <[email protected]>* @copyright 2007-2014 PrestaShop SA* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)* International Registered Trademark & Property of PrestaShop SA*}<script type="text/javascript"> {if $universal_analytics eq true} {literal} (function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); {/literal} ga('create', '{$ganalytics_id|escape:'htmlall':'UTF-8'}'{if isset($pageTrack)}, '{$pageTrack|escape:'htmlall':'UTF-8'}'{/if}); {if $isOrder eq true} ga('require', 'ecommerce', 'ecommerce.js'); {else} ga('send', 'pageview'); {/if} {if $isOrder eq true} ga('ecommerce:addTransaction', { 'id': '{$trans.id|escape:'htmlall':'UTF-8'}', 'affiliation': '{$trans.store|escape:'htmlall':'UTF-8'}', 'revenue': '{$trans.total|escape:'htmlall':'UTF-8'}', 'tax': '{$trans.tax|escape:'htmlall':'UTF-8'}', 'shipping': '{$trans.shipping|escape:'htmlall':'UTF-8'}', 'city': '{$trans.city|escape:'htmlall':'UTF-8'}', 'state': '{$trans.state|escape:'htmlall':'UTF-8'}', 'country': '{$trans.country|escape:'htmlall':'UTF-8'}', 'currency': '{$trans.currency|escape:'htmlall':'UTF-8'}' }); {foreach from=$items item=item} ga('ecommerce:addItem', { 'id': '{$item.OrderId|escape:'htmlall':'UTF-8'}', 'sku': '{$item.SKU|escape:'htmlall':'UTF-8'}', 'name': '{$item.Product|escape:'htmlall':'UTF-8'}', 'category': '{$item.Category|escape:'htmlall':'UTF-8'}', 'price': '{$item.Price|escape:'htmlall':'UTF-8'}', 'quantity': '{$item.Quantity|escape:'htmlall':'UTF-8'}' }); {/foreach} {literal} (function() { {/literal}{if $isOrder eq true}{literal} var key = 'ga_trans'; var idtrans = {/literal}{$trans.id|intval}{literal}; if (!!$.prototype.totalStorage) var view_ga_trans = parseInt($.totalStorage(key)); else if (typeof localStorage !== 'undefined' && localStorage) var view_ga_trans = parseInt(localStorage.getItem(key)); if (typeof view_ga_trans !== 'undefined' && view_ga_trans > 0 && idtrans == view_ga_trans ) return false; if (!!$.prototype.totalStorage) $.totalStorage(parseInt(key, idtrans)); else if (typeof localStorage !== 'undefined' && localStorage) localStorage.setItem(key, parseInt(idtrans)); {/literal}{/if}{literal} ga('ecommerce:send'); })(); {/literal} {/if} {else} var _gaq = _gaq || []; _gaq.push(['_setAccount', '{$ganalytics_id|escape:'htmlall':'UTF-8'}']); // Recommended value by Google doc and has to before the trackPageView _gaq.push(['_setSiteSpeedSampleRate', 5]); _gaq.push(['_trackPageview'{if isset($pageTrack)}, '{$pageTrack|escape:'htmlall':'UTF-8'}'{/if}]); {if $isOrder eq true} {* If it's an order we need more data for stats *} _gaq.push(['_addTrans', '{$trans.id|escape:'htmlall':'UTF-8'}', {* order ID - required *} '{$trans.store|escape:'htmlall':'UTF-8'}', {* affiliation or store name *} '{$trans.total|escape:'htmlall':'UTF-8'}', {* total - required *} '{$trans.tax|escape:'htmlall':'UTF-8'}', {* tax *} '{$trans.shipping|escape:'htmlall':'UTF-8'}', {* shipping *} '{$trans.city|escape:'htmlall':'UTF-8'}', {* city *} '{$trans.state|escape:'htmlall':'UTF-8'}', {* state or province *} '{$trans.country|escape:'htmlall':'UTF-8'}' {* country *} ]); {foreach from=$items item=item} _gaq.push(['_addItem', '{$item.OrderId|escape:'htmlall':'UTF-8'}', {* order ID - required *} '{$item.SKU|escape:'htmlall':'UTF-8'}', {* SKU/code - required *} '{$item.Product|escape:'htmlall':'UTF-8'}', {* product name *} '{$item.Category|escape:'htmlall':'UTF-8'}', {* category or variation *} '{$item.Price|escape:'htmlall':'UTF-8'}', {* unit price - required *} '{$item.Quantity|escape:'htmlall':'UTF-8'}' {* quantity - required *} ]); {/foreach} {* submits transaction to the Analytics servers *} {literal} _gaq.push(['_trackTrans']); {/literal} {/if} {literal} (function() { {/literal}{if $isOrder eq true}{literal} var key = 'ga_trans'; var idtrans = {/literal}{$trans.id|intval}{literal}; if (!!$.prototype.totalStorage) var view_ga_trans = parseInt($.totalStorage(key)); else if (typeof localStorage !== 'undefined' && localStorage) var view_ga_trans = parseInt(localStorage.getItem(key)); if (typeof view_ga_trans !== 'undefined' && view_ga_trans > 0 && idtrans == view_ga_trans ) return false; if (!!$.prototype.totalStorage) $.totalStorage(parseInt(key, idtrans)); else if (typeof localStorage !== 'undefined' && localStorage) localStorage.setItem(key, parseInt(idtrans)); {/literal}{/if}{literal} var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); {/literal} {/if}</script> Appendix 2: (My adwords code with my ID's removed) <!-- START Google Code for Order Conf Conversion Page --><script type="text/javascript">/* <![CDATA[ */var google_conversion_id = YOUR ID HERE;var google_conversion_language = "en";var google_conversion_format = "3";var google_conversion_color = "ffffff";var google_conversion_label = "YOUR LABEL HERE";var google_conversion_value = {$trans.total};var google_conversion_currency = "GBP";var google_remarketing_only = false;/* ]]> */</script><script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script><noscript><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/YOURVALUE/?value=0.00¤cy_code=GBP&label=YOURLABEL&guid=ON&script=0"/></div></noscript><!-- END Google Adwords Code for Order Conf Conversion Page --> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now