Jump to content

[SOLVED] Where should I paste my Google Analytics code?


Recommended Posts

Hello,

 

I am attempting to add Google Analytics to my Prestashop.

 

Google says, "

You'll get a tracking code to paste onto your pages so Google knows when your site is visited."

 

 

In what pages should I add this code to? Do I want to add it to just one page? and which one?

 

Thank you.

 

Any and all help is appreciated.

Share this post


Link to post
Share on other sites

Hi, your google analytics code should like something like this:

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
  _gaq.push(['_setCustomVar', 1, 'Authenticated', 'Yes', 1]);
  _gaq.push(['_trackPageview']);
 (function() {
	 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);
  })();
</script>

 

The only *best* place to paste this code is in you themes/THEME_NAME/header.tpl

just before the closing </head> tag

  • Like 1

Share this post


Link to post
Share on other sites

Let Prestashop do it for you. The steps to get this working are:

  • Go to the Google Analytics website, sign up for an account. A Tracking ID and a snippet of Tracking Code will be generated for you (you have these).
  • (Install and) configure the Prestashop Google Analytics module by copying the Tracking ID into the Your username box & click Update ID
  • Ignore the snippet of Tracking Code from Google - the Prestashop module will use the Tracking ID to generate the required code snippet within your shop.
  • Check the Status on your Google Analytics account to see when it is set to 'Tracking Installed'. At that point (should be within 24 hrs), data will start being collected and then you can use the reporting function.

  • Like 2

Share this post


Link to post
Share on other sites

Hello,

 

I added the code to the header.tpl as instructed however it made the page not render at all. I've decide to use the prestashop module to avoid problems during rendering.

 

Stottycabanas, Can you tell me which google analytics module you are referring to? It appears there are several in the addon shop.

 

Thanks!

Edited by ritabarr (see edit history)

Share this post


Link to post
Share on other sites

Ritabarr, I didn't get it from the addons shop - I definitely didn't pay any money for it. I'm pretty sure it was already there in the list of modules in version 1.5.4.1.

 

Before installing it, it was towards the bottom of the list of modules and looked like this:

post-578343-0-03529800-1377126871_thumb.png

 

After installation, it was in alphabetical order under 'G' and looked like this:

post-578343-0-24433600-1377126870_thumb.png

  • Like 2

Share this post


Link to post
Share on other sites

 Share

×
×
  • Create New...

Important Information

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