Page 1 of 1

adding google analytics

Posted: Mon Jul 29, 2013 10:14 am
by foley13
Hi,
I'm having trouble with adding google analytics to a site. I've followed what I've found on the internet and created a global content block called "analytics" and added {literal} UA-3730606 {/literal} to that block. I have then added {global_content name="analytics"} to my templates but the actual analytics code is showing on my site, how do I make it so it's hidden?

Thankyou.

Re: adding google analytics

Posted: Mon Jul 29, 2013 10:30 am
by velden
Make sure to disable the WYSIWYG editor first for that content block!

Further I'd assume you have to put the whole analytics code inside the content block

Code: Select all

<__script__ type="text/javascript">
{literal}
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-Y']);
  _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);
  })();
{/literal}
</__script>

Re: adding google analytics

Posted: Tue Jul 30, 2013 3:12 pm
by foley13
Thankyou Velden, that worked perfectly.

Re: adding google analytics

Posted: Tue Jul 30, 2013 4:01 pm
by staartmees
Please add [solved] to the title