Installing Google Analytics on Joomla

From WBITT's Cooker!

Jump to: navigation, search

JA_Purity_ii is different template than the normal Joomla template. Edit HTML in the templates web interface does not provide the place to put in the google script code.

[root@www ~]# cd /var/www/vhosts/wbitt.com/httpdocs/templates/ja_purity_ii/layouts/blocks

Change :

<!--[if IE 7.0]>
<style>
.clearfix { display: inline-block; } /* IE7xhtml*/
</style>
<![endif]-->

<script type="text/javascript">
var siteurl='<?php echo $this->baseurl();?>';
var tmplurl='<?php echo $this->templateurl();?>';
</script>

To:

<!--[if IE 7.0]>
<style>
.clearfix { display: inline-block; } /* IE7xhtml*/
</style>
<![endif]-->

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-838bzay-x']);
  _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>

<script type="text/javascript">
var siteurl='<?php echo $this->baseurl();?>';
var tmplurl='<?php echo $this->templateurl();?>';
</script>


OR

[root@www ~]# cd /var/www/vhosts/wbitt.com/httpdocs/templates/ja_purity_ii/layouts/

[root@www layouts]# vi default-joomla.php 

[root@www layouts]# vi default.php 

Now, add the code: from the google analytics page of your website's profile page:

Before editing:

<head>
<?php $this->loadBlock('head') ?>
</head>

After editing:

<head>
<?php $this->loadBlock('head') ?>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-838bzay-x']);
  _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>
</head>
Personal tools