adding google analytics

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
foley13
Forum Members
Forum Members
Posts: 10
Joined: Mon Apr 08, 2013 9:51 am

adding google analytics

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: adding google analytics

Post 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>
foley13
Forum Members
Forum Members
Posts: 10
Joined: Mon Apr 08, 2013 9:51 am

Re: adding google analytics

Post by foley13 »

Thankyou Velden, that worked perfectly.
staartmees
Power Poster
Power Poster
Posts: 1049
Joined: Wed Mar 19, 2008 4:54 pm

Re: adding google analytics

Post by staartmees »

Please add [solved] to the title
Post Reply

Return to “The Lounge”