Page 1 of 2

Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 4:38 am
by steveharman
Hi!

I just pasted my Google Analytics tracking code into System > Settings > [my store] > Server > 'Google Analytics Code:' box and the tracking code is showing up on my store's home page. i.e; visible to users.

In fact it's on every page at the very top left of the screen. I'm using the default unmodified template on a totally fresh install.

Bug? Or me? ;-)

Thanks,

Steve

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 5:16 am
by Johnathan
Just you. :) Make sure you're including the <script> tags that surround the code.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 3:48 pm
by Daniel
steveharman wrote:Hi!

I just pasted my Google Analytics tracking code into System > Settings > [my store] > Server > 'Google Analytics Code:' box and the tracking code is showing up on my store's home page. i.e; visible to users.

In fact it's on every page at the very top left of the screen. I'm using the default unmodified template on a totally fresh install.

Bug? Or me? ;-)

Thanks,

Steve

you!

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 5:13 pm
by steveharman
You are both correct! ;-) And thanks it's working fine now.

In fairness though; bit ambiguous in the admin page, code or code?

System > Settings > Server > Google Analytics Code box says, and I quote, "Login to your Google Analytics account and after creating your web site profile copy and paste the analytics code into this field." Fine so my analytics code is UA-xxxyyz44-1 and away I go. Perhaps like many others I suspect, I'd assumed OpenCart had the JavaScript in place which it wrapped around my UA-xxxyyzz "analytics code" that I put in the appropriate box.

No big deal, just a slight usability clarification for future users perhaps?

Thanks again folks.

Steve

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 7:37 pm
by mavibrick
steveharman wrote:You are both correct! ;-) And thanks it's working fine now.

In fairness though; bit ambiguous in the admin page, code or code?

System > Settings > Server > Google Analytics Code box says, and I quote, "Login to your Google Analytics account and after creating your web site profile copy and paste the analytics code into this field." Fine so my analytics code is UA-xxxyyz44-1 and away I go. Perhaps like many others I suspect, I'd assumed OpenCart had the JavaScript in place which it wrapped around my UA-xxxyyzz "analytics code" that I put in the appropriate box.

No big deal, just a slight usability clarification for future users perhaps?

Thanks again folks.

Steve
Hi I'am sorry but i couldn't manage it. How did you solve this problem. What do you guys mean with script surrounding the code? please help. Can't get this work out.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 8:16 pm
by steveharman
Hi!

At the section of Google's Analytics site ('Admin') which displays your unique tracking code (usually begins with UA....), there should also be a chunk of HTML / JavaScript code shown at the bottom of the page. It'll be something like this:

Code: Select all

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxxx-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>
Notice your own tracking code will be shown where my example has UA-xxxxxxxx. Copy and paste that entire block of code from Google's site and put that into OpenCart at System > Settings > [your site] > Server > 'Google Analytics Code:' (scroll to bottom of page).

That's where I fell down, OpenCart asks for 'Google Analytics Code' and I gave it... my Google Analytics code! What OpenCart actually needed was the Analytics code and all the supporting JavaScript etc.

Seems to work fine now.

HTH

Steve

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Mar 15, 2012 8:57 pm
by mavibrick
Hi Steve,

Now it's clear. Thank you very much for your help.

Mavi

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Tue May 08, 2012 6:53 am
by gail315
What if you have multiple stores? Each domain has a different Google Analytics Code . How do you give each store the correct Google Analytics Code ? ???

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Mon May 21, 2012 6:30 pm
by kimsonvu
I have same question with gail315!

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Mon Nov 12, 2012 10:10 am
by lperagallo
Has anyone figured out how to get Google analytics code set up for multiple stores? I have two stores configured and two unique codes from google, but I have no idea how to set this up to work and can't find a post any where about it.

Lou

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Mon Nov 12, 2012 10:23 am
by lperagallo
OK,

I put the code below and google keeps reporting:

Tracking ID

UA-36229666-1


Status: Tracking Not Installed.

Any idea how to fix this?

Code is in the box in SYSTEM, SETTINGS, Hobby-drones store, SERVER tab:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36229666-1']);
_gaq.push(['_setDomainName', 'hobby-drones.com']);
_gaq.push(['_setAllowLinker', true]);
_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>

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Tue Nov 13, 2012 12:55 am
by gail315
Lou...

I am using this FREE extension 8) for the Multistore Google Anayltics:
http://www.opencart.com/index.php?route ... on_id=6571

Gail

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Jan 03, 2013 5:59 pm
by sambick2
lperagallo wrote:OK,

I put the code below and google keeps reporting:

Tracking ID

UA-36229666-1


Status: Tracking Not Installed.

Any idea how to fix this?

Code is in the box in SYSTEM, SETTINGS, Hobby-drones store, SERVER tab:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36229666-1']);
_gaq.push(['_setDomainName', 'hobby-drones.com']);
_gaq.push(['_setAllowLinker', true]);
_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>
Ok, go via ftp to the catalog-view-theme-your_theme-template-common folder. Find header.tpl file. Backup it. Open it and find <body>. Below this paste a code from google analytic like:

Code: Select all

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxx-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>
Save the header.tpl . Check your google analytic on http://www.google.com/analytics/

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Thu Apr 04, 2013 7:06 pm
by alexascj
Hello,

please help me too:D I`ve put the code in the space dedicated in system not working, i`ve put the code in the script head and footer...still not working. Ideas?

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Tue Apr 09, 2013 12:59 am
by jbcul
Good Posting. I too slammed in my code thinking "code" meant the number UA - xxxxxxxx-x only to read this post and realize that code meant the full tracking code. Thanks much. Our store has not gone live yet so I can't test much but it appears to be working.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Sat Nov 09, 2013 9:52 am
by atzi
Great post. Wish we could rate forum posts, I would rate this a very helpful.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Sun Dec 22, 2013 7:09 pm
by sml
Same confusion for me also ... I thought that the Google Analytics code was just the UAxxxxx code.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Sun Dec 22, 2013 9:30 pm
by labeshops
Just an fyi - you can put any code you need to add to the header in this box, not just google analytics. I'm using the multistore mod now and can add my alexa, yahoo shopping, and other verification code lines (the complete < code > ) into the box along with the Google Analytics one easily for any store at any time. Very helpful.

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Wed Nov 12, 2014 12:35 am
by Dhaupin
labeshops wrote:Just an fyi - you can put any code you need to add to the header in this box, not just google analytics. I'm using the multistore mod now and can add my alexa, yahoo shopping, and other verification code lines (the complete < code > ) into the box along with the Google Analytics one easily for any store at any time. Very helpful.
You shouldn't use the analytics code box for anything besides Google analytics. Other mods use it like an object sometimes. For example ecommerce tracking takes it out of header and puts before foot on order complete page. If you had other mods in the box that depended on closing head location, they might wonk out.

I realize this is a way old thread, but its coming up for searches. We made a free mod to help with this stuff regarding more code boxes and multi-store compatibility. Should help solve some of this and extend code boxes for things like live chat, otmizely, tag manager, etc: http://www.opencart.com/index.php?route ... n_id=19485

Re: Google Analytics code visible on-screen in 1.5.2.1

Posted: Sun Jan 31, 2016 7:20 pm
by mtjhost
Hi I unable to Find the Google analytic tracking option in server. Is there something wrong with my installation? Its 2.1.0.2 Install.

Where I should rectify the same.