Business Magazine

Installing Google Analytics for Magento, Joomla, Drupal and non-CMS Websites.

Posted on the 18 November 2014 by Andykinsey @andykinsey

Installing Google Analytics for Magento, Joomla, Drupal and non-CMS websites.

There are a plethora of Content Management Systems, such as WordPress, Magento, Joomla etc etc. Earlier, I spoke about installing Google Analytics to WordPress, some people have asked what about other CMS’s and those without a CMS, so I want to give you a list of plugins or tools I used for installing Google Analytics.

Why I Recommend Using a Plugin for Google Analytics

Before moving on I want to answer a question from the previous post (GA for WordPress) about why I suggest using a plugin, even over using the inbuilt code of a theme.

The answer is pretty simple. A plugin, such as those below, will usually offer much more flexibility in your tracking code and use the latest versions of the code from Google.

I have experienced multiple times that you enter in your tracking id into a theme’s options, UA-xxxx, and all it does is insert the standard code or adds the code and bits of e-commerce. Thats nice if all you want is numbers about who visits where and for how long, but using a plugin you can ask it to append actions such as an Event or campaign ID to a link automatically if it is not within your domain (so you can track clicks to outbound links), you can set it to pass through certain information and ignore certain user types etc etc.

Plugins ultimately are better in my view for this kind of thing. They will work in the same way, regardless of theme, and as such can be relied on to deliver the data (in this case) to Google Analytics. But that’s just my view and I know there are other opinions on this out there.

Which Google Analytics Plugin is the best…

Google Analytics for Magento

I recommend the use of Google Universal Analytics by Aromicon.

This plugin is simple to use and install, it has a simple admin-end interface so you don’t get confused (there are so many plugins that confuse me). It is a 2 or 3 minute setup, unlike some plugins for magento there is no need to change your theme, also there are new updates regularly to add more features to enable you to get more data from Google Analytics.

Google Analytics for Joomla

For Joomla I would recommend the Asynchronous Google Analytics plugin by nicheextensions.

Don’t be fooled by the name AGA is pretty much the simplest and best way to add GA to your Joomla website. It was initially developed for the old Classic Tracking Code (hence the name) and now supports both Universal Analytics and Classic. It does cost around $5usd for the pro versions but this adds more options, such as Enhanced in-page analytics, link attribution and more.

Google Analytics for Drupal

The drupal module I recommend is “google analytics” by ixis.

This is a 5 star plugin for my money and supports pretty much every Universal Analytics feature there is, and its updated very regularly. The plugin even goes as far as supporting DNT by default which shows that its built with the future in mind and user privacy. The module/plugin has around 10 regular committers with a number of other developers chipping in, meaning that the code behind this plugin can be relied on.

Google Analytics for those without a CMS

If you do not have a CMS then you are stuck without lots of features, such as finding the number of downloads of a resource, however all is not lost. The code below will allow you to make the most of Google Analytics in your small bit of the world wide web, there’s plenty it won’t do but it will give you more data than the default Universal Analytics Tracking Code.

Google Analytics Code: Replace UA with your own code before using

<script type=”text/javascript”>// <![CDATA[
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’__gaTracker’);

__gaTracker(‘create’, ‘UA-XXXXXX-X’, ‘auto’);
__gaTracker(‘require’, ‘displayfeatures’);
__gaTracker(‘send’,’pageview’);
// ]]></script>

Copy this to just before your tag.

Oh, we can also track outbound links as events too…

<script>!function(){var t=function(t,e){e?window.open(t,e):window.location.href=t},e=function(t,e,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent(“on”+e,function(){n.call(t)})};if(document.getElementsByTagName)for(var n=document.getElementsByTagName(“a”),i=document.domain.split(“.”).reverse()[1]+”.”+document.domain.split(“.”).reverse()[0],a=0;a<n.length;a++){var o=”string”==typeof n[a].getAttribute(“href”)?n[a].getAttribute(“href”):””,r=o.match(i);(o.match(/^https?\:/i)&!r||o.match(/^mailto\:/i))&e(n[a],”click”,function(e){var n=this.getAttribute(“href”),i=”string”==typeof this.getAttribute(“target”)?this.getAttribute(“target”):””;console.log(“add event”,n),ga(“send”,”event”,”outbound”,”click”,n,{hitCallback:t(n,i)},{nonInteraction:1}),e.preventDefault()})}}();</script>

Do not edit the above. Simply paste it to your code just before your tag.
Special thanks to ExisWeb for this code.

So thats most of the web covered, there are many other CMS’s out there and lots more you can do. If you use another CMS and want my advice on what to use for tracking using that CMS, leave a comment below.

Original SEO Content by SEOAndy @ Installing Google Analytics for Magento, Joomla, Drupal and non-CMS websites.


Back to Featured Articles on Logo Paperblog