Jump to content

Recommended Posts

We have a problem with Google Analytics Module Version 1.6

 

We have update the version 1.4.3 of the ganalytics module using prestashop (1.5.4.1) backoffice to the new version 1.6

 

Analytics now doesn't work, we have tried to reinstall, disable, reset the module but nothing changes.

 

It seems that the analytics code is present in our pages ( www.betafer.it )but it is not correct.

 

How can we solve ?

 

We need to create a new ticket in prestashop forge ?

 

Best Regards.

Share this post


Link to post
Share on other sites

Same here, working on finding a solution :)

Share this post


Link to post
Share on other sites

Five ^_^

 

We have placed analytics code in the footer but we hope to use the module ....

Share this post


Link to post
Share on other sites

It seems that  enabling universal analytics works for me. Weird

Share this post


Link to post
Share on other sites

Did anybody figure this out - I have the same problem and I have no idea how to set up my shop with analytics...

Share this post


Link to post
Share on other sites

you also updated from 1.6 on prestashop 1.5.4.1 ?

Share this post


Link to post
Share on other sites

I have same issue with ganalytics.

 

I updated from 1.5 to 1.6 and I tried install/reinstall with no exit. I see the Analytics script but doesnt works: URL: http://coteseduction.com/

 

The error message that shows the Chrome plugin Tag Assistant is "Error: Invalid or missing web property ID"

 
I have no clue how to solve it.

Share this post


Link to post
Share on other sites

Well, I've modified the file header.tpl of ganalytics module and copy/paste the Google Analytics code and now works.... It's really weird but works...

Share this post


Link to post
Share on other sites

I'm having the same problem with google analytics not working.. I've tried all the solutions as listed above and none seemed to have solved the issue. my version of prestashop is 1.6

Share this post


Link to post
Share on other sites

Where exactly do you add the single line to update the Analytics tracking code to support Display Advertising?

 

The header.tpl file I am using is from here: https://github.com/PrestaShop/PrestaShop-modules/blob/master/ganalytics/views/templates/hook/header.tpl

 

I changed for both UA and Classis, but still no result: "Tracking code changes needed (as of Jul 10, 2014, 4:33:53 PM).

Your Analytics tracking code does not include the necessary support for the Demographics and Interest reports. Learn more about the simple, one-line, one-time change to your tracking code to add this support.

 

Below is my header.tpl file.

<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');
    ga('require', 'displayfeatures');
    {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';*}
        ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
    {/literal}
    {/if}
</script>

Share this post


Link to post
Share on other sites

Dear nzecheru,

 

 The problem with google code validation for Demographics is a well known problem and has been discussed enough on googles product forums.

 

 If you read some topics there, you will realize that since the correct code appears when you preview the source code output of your website with your browser, you can just press "Skip validation" button and it will work. You wiil get a "success" message form google on the next step.

 

As with your code just move the ga('require', 'displayfeatures'); after the {else} and before  the ga('send', 'pageview');

 

Everything else seems fine to me.

 

If you are using P.S 1.6.8 like me it will work. Here is the code I use :

{*
* 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 license@prestashop.com 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 <contact@prestashop.com>
*  @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}, 'auto');
    
    {if $isOrder eq true}
    ga('require', 'ecommerce', 'ecommerce.js');
    {else}
    ga('require', 'displayfeatures');
    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://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
    {/literal}
    {/if}
</script>

Good luck, and feel free to come back if it won't work for you.

 

 

(Details about validation problem here :https://productforums.google.com/forum/#!searchin/analytics/not$20validating|sort:relevance/analytics/_C2M4pZ9sEI/6r68GHifH5EJ)

Edited by skechav (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

If you read in the official google documentation here https://support.google.com/analytics/answer/2819948?hl=en

right at the bottom it says:

 

Click Validate tracking code. Analytics then checks to see whether you made the correct change to your code. If the validation fails, then you see this same page again.

Analytics may be unable to validate your code changes under the following circumstances:

  • You are using Google Tag Manager or a third-party tag manager to include the Analytics tracking code on your pages.
  • You have included comments in your tracking code.
  • You are hosting dc.js on your own servers, or including it from an external script.

If you are certain that you’ve made the correct change, you can click Skip validation.

With the reports enabled and the tracking-code modification in place, you should see data in your reports within 24 hours.

 

I hope it helps to clarify

  • Like 1

Share this post


Link to post
Share on other sites

Dear nzecheru,

 

 The problem with google code validation for Demographics is a well known problem and has been discussed enough on googles product forums.

 

 If you read some topics there, you will realize that since the correct code appears when you preview the source code output of your website with your browser, you can just press "Skip validation" button and it will work. You wiil get a "success" message form google on the next step.

 

As with your code just move the ga('require', 'displayfeatures'); after the {else} and before  the ga('send', 'pageview');

 

Everything else seems fine to me.

 

If you are using P.S 1.6.8 like me it will work. Here is the code I use :

{*
* 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 license@prestashop.com 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 <contact@prestashop.com>
*  @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}, 'auto');
    
    {if $isOrder eq true}
    ga('require', 'ecommerce', 'ecommerce.js');
    {else}
    ga('require', 'displayfeatures');
    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://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
    {/literal}
    {/if}
</script>

Good luck, and feel free to come back if it won't work for you.

 

 

(Details about validation problem here :https://productforums.google.com/forum/#!searchin/analytics/not$20validating|sort:relevance/analytics/_C2M4pZ9sEI/6r68GHifH5EJ)

 

 

Hello!

 

Not work to me  :wacko:

 

I have Prestashop 1.6.0.9

 

Version  nginx/1.7.1
 
Version  PHP 5.5.9-1ubuntu4.3
 
File:  /modules/ganalytics/views/templates/hook/header.tpl
 
 
Can anyone help me?
 
Best regards

Share this post


Link to post
Share on other sites

hello jhd

you have some visible errors  related to this code ? 

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

 

I see no error.

 

I can not validate the tracking code

 

Thanks!

Share this post


Link to post
Share on other sites

same problem on my site, also ganalytics is not tracking my sales in the e-commerce tab...

  • Like 1

Share this post


Link to post
Share on other sites

Good morning!

 

I have now pressed the check button, and verified.  :unsure:  :)

 

Enhorabuena.

Ha habilitado correctamente los Informes demográficos. Aunque puede acceder a ellos ahora, es posible que transcurran hasta 24 horas antes de que haya datos disponibles en dichos informes.

Obtenga más información acerca de los nuevos informes.
Congratulations. 
You have successfully enabled demographic reports. Although you can access them now, it may take up to 24 hours before it becomes available in those reports. 
Learn more about the new reports.

 

Best regards

Edited by jhd (see edit history)

Share this post


Link to post
Share on other sites

I tried to delete and reinstall, but it doesn't help... Can I have some settings wrong in google analytics? Or do you have suggestions for me about what you did?

Share this post


Link to post
Share on other sites
nine months and no one has yet solved the problem .. 

Must be a whole ^ _ ^

  • Like 1

Share this post


Link to post
Share on other sites

 

nine months and no one has yet solved the problem .. 
Must be a whole ^ _ ^

 

The problem IS solved. I run two different sites of PS 1.6.8 and 1.6.9 this way and both of them get demographic details. Please, read the post carefully and do not rush.Also, it would be very helpful to add some extra details about the problem you face when saying that it doesn't work, so we could probably help you out.

 

Good luck!

Share this post


Link to post
Share on other sites

Thank you skechav!

Dear Nzecheru,

I m happy that it helped somehow. I just would like to know if you finally really solved the problem this way by modified the header.tpl code as described and by pressing the "Skip validation" Button on googles' panel.

 

Have a nice day :)

Share this post


Link to post
Share on other sites
Display Analytics PrestaShop
 
Google Analytics v2.0.4 - by PrestaShop
 
PS 1.6.0.9 
 
File:  /modules/ganalytics/ganalytics.php
Line: 199 add ga(\'require\', \'displayfeatures\');
 
Example:
 
<script type="text/javascript">
(window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\');
(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\');
ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');
'.($back_office ? 'ga(\'require\', \'ecommerce\');' : '').'
ga(\'require\', \'ec\');ga(\'require\', \'displayfeatures\');
</script>';

 

Salutacions,

Gesdi Barcelona

Edited by gesdi (see edit history)

Share this post


Link to post
Share on other sites

Hi, 

Current code did change a bit it seems. I need to add ga(\'require\', \'displayfeatures\'); for the remarketing (If hits sent to your web property do not include Advertising Features data, you won't be able to use Advertising Features).

 

The current code in 1.6.0.9 ganalytics v2.0.9

File:  /modules/ganalytics/ganalytics.php

 

Looks like this:

<script type="text/javascript">
				(window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\');
				(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\');
				ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');
				ga(\'require\', \'ec\');
				'.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '').'
			</script>';

I changed the code to:

	<script type="text/javascript">
				(window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\');
				(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\');
				ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');
				ga(\'require\', \'ec\');ga('require', 'displayfeatures');
				'.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '').'
			</script>';
	}

But this gave an error:

 

[PrestaShop] Fatal error in module ganalytics:
syntax error, unexpected 'require' (T_REQUIRE)

 

How should i include the code: ga(\'require\', \'displayfeatures\'); to enable remarketing?

Share this post


Link to post
Share on other sites

You have this error because you have in code:

ga('require', 'displayfeatures');

its correct:

ga(\'require\', \'displayfeatures\');
  • Like 1

Share this post


Link to post
Share on other sites

 

nine months and no one has yet solved the problem .. 
Must be a whole ^ _ ^

 

 

I do agree with Gipielle after a year  the problem is still existant since not a single person from the team fixed the error upstream.

Each new version pushed by the infamous addons, has still the bug burried in.

 

A shame!

Share this post


Link to post
Share on other sites

We could add it ourself in github? But i dont know github..

Share this post


Link to post
Share on other sites

Hello,

I have the same problem...

 

Imposible to track Analytics. 

 

http://dilataciones.com

 

I tried to do by module, developing myself, nothing... nothing to do... put the analytics code omg.. I did it more than 50 times...

 

Someone know what is happening? Omg

 

Cheers,

Share this post


Link to post
Share on other sites

I have had same problem. And solved it.


Google analytics module had couple of errors in source code in modules/ganalytics/ganalytics.php


and it was generating incorrect code.


To fix it edit the file


go to line 259 and replace code with this:


 


<script>

 

(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\');

ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');

ga(\'send\', \'pageview\');'

.(($user_id && !$back_office) ? 'ga(\'set\', \'&uid\', \''.$user_id.'\');': '')

.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '')

.'</script>';


 

ORIGINALLY IT WAS:


<script type="text/javascript">

(window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\');

(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\');

ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');

ga(\'require\', \'ec\');'

.(($user_id && !$back_office) ? 'ga(\'set\', \'&uid\', \''.$user_id.'\');': '')

.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '')

.'</script>';

  • Like 1

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More