What is Google Analytics?
Google Analytics is the most popular service to track website traffic. With it, you can easily see info like session duration, opened pages per session, bounce rate, in which country is your site most popular…the list is endless. You get a dashboard with all the general info, presented neatly and accurately. You can click on each of the sections and get much more detailed info. It’s all very modular and you can set it up to your liking. Add charts, graphs, whatever floats your boat. It works by adding a tag, a snippet of code which is made for your site.
Adding Google Analytics on my Joomla page
There are a few ways to enable Google Analytics on your paga. Let’s start with the easy way:
Install a plugin responsible for embedding Google Analytics
A simple search in the Joomla Extensions Directory will reveal a plethora of plugins that can help you in adding Google Analytics to your site. For this article, I will be using Advanced Google Analytics by Alin Marcu. The general idea is the same, whichever plugin you use.
If you have trouble installing extensions, you can always check out our How to find & install a Joomla extension article.
So, after installing the plugin, you need to enable it.
- Go to Extensions -> Plugins
- Find your newly installed plugin
- Open it and set the Status to Enabled
Enter your Google Analytics ID and your Domain name in the relevant fields and hit Save.
That was it! You can check if Analytics are working by searching for a code snippet in the <head>
of your site.
<script type="text/javascript">
(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','ga'); ga('create', '', 'auto'); ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
Do it manually
To implement Google Analytics manually, you need to edit the template and include the code required for Analytics to function. One thing to note is that there is no standard way to do this, it depends on the template you are using.
Since Protostar is the default template on all Joomla 3.x sites, these steps will be explained for that template in mind.
- Log to the Administrator part of your site
- Go to Extensions -> Templates -> Templates
- Click on Protostar Details and Files
- Open index.php and paste the code snippet just below
<head>
- Click Save
That should be it. Refresh your site and check if everything is present in your code.
There are some templates that have dedicated fields for adding Analytics code. You don’t need to manually paste the code in index.php, simply paste it in the relevant field. It all depends on the template you use. Snoop around the Template options and you might find a lot of fields that help your workflow.
In a few days, you will get some great insight into your sites performance and you can act accordingly.
This concludes this article. Hopefully you learned something new and are going to make the most of the newly found information about your site.
After adding Google Analytics, you might want to add Google Tag Manager to your site. Those two work in conjunction and offer even more information. Read our article on Adding Google Tag Manager.