Installing Google Analytics on Joomla

From WBITT's Cooker!

(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
<pre>
<pre>
-
[root@www layouts]# pwd
+
[root@www ~]# cd /var/www/vhosts/wbitt.com/httpdocs/templates/ja_purity_ii/layouts/blocks
-
/var/www/vhosts/wbitt.com/httpdocs/templates/ja_purity_ii/layouts
+
</pre>
-
[root@www layouts]#  
+
 
 +
Change :
 +
<pre>
 +
<!--[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>
 +
</pre>
 +
 
 +
To:
 +
<pre>
 +
<!--[if IE 7.0]>
 +
<style>
 +
.clearfix { display: inline-block; } /* IE7xhtml*/
 +
</style>
 +
<![endif]-->
 +
 
 +
<script type="text/javascript">
 +
 
 +
  var _gaq = _gaq || [];
 +
  _gaq.push(['_setAccount', 'UA-8383389-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>
 +
 
 +
<script type="text/javascript">
 +
var siteurl='<?php echo $this->baseurl();?>';
 +
var tmplurl='<?php echo $this->templateurl();?>';
 +
</script>
 +
 
 +
</pre>
 +
 
 +
 
 +
<b>OR</b>
 +
 
 +
<pre>
 +
[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-joomla.php  
Line 11: Line 59:
</pre>
</pre>
-
Add the code: from the google analytics page of your website's profile page:
+
Now, add the code: from the google analytics page of your website's profile page:
Before editing:
Before editing:

Revision as of 18:15, 5 March 2011

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-8383389-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>

<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