eZ Community » Forums » Install & configuration » Different Google Analytics Code per...
expandshrink

Different Google Analytics Code per Siteaccess

Different Google Analytics Code per Siteaccess

Sunday 20 January 2013 10:27:51 pm - 6 replies

Hi all,

It's possible to have a different Google Analytics code for each of my siteaccess's?

Thanks in advance,

João Duarte

Monday 21 January 2013 2:11:10 pm

Hi,

Having a different GA code per siteaccess means that you have to create a design per siteaccess and a template per design, containing the GA code.

Monday 21 January 2013 6:12:30 pm

Or read the google analytics key in the template from an ini file, keep the same template for all siteaccesses and just change the ini.

Thursday 24 January 2013 6:02:24 pm

Hi,

Many thanks for the answers... If I add one property to site.ini.append.php:

[GoogleAnalytics]
Urchin=UA-nnnnnnn-n

How can i read it in pagelayout.tpl? ... or in a template?

Also, how can I pass the value to the script?

Thanks again,

João Duarte

Thursday 24 January 2013 6:45:56 pm

Found the answer for my first question:

 {def $urchin = ezini('GoogleAnalytics','Urchin')}

Still don't know how to pass the variable from the template into the script...

Any suggestions?! ...

Thanks,

João

Thursday 24 January 2013 7:05:28 pm

Hi Joao, 

It can totally look like this: 

<!-- BEGIN GA tracker script -->
<script type="text/javascript">
{literal}
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '{/literal}{ezini('GoogleAnalytics','Urchin')}{literal}']);
  _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>
<!-- END GA tracker script -->

I hope this helps,
Cheers, 

Thursday 24 January 2013 7:30:27 pm

That's it!!

Thanks a lot for the help!!

João

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from