Google Analytics is a powerful and free tool for analising traffic coming to your site. When running a website it is often crucial to understand where your traffic is been sourced from and how your traffic behaves once they reach your site. For this Google Analytics is the ideal solution.
To obtain this information Google Analytics uses some tracking code loaded in to every page of your site. Before we start you will need to retrieve this code from your Google Analytics account. For details on doing so may I suggest the following article here.
Here we will describe two methods of adding this code to your template.
The first method uses the Custom Code field found in some of our more recent template releases and couldn't really be much easier. From your Joomla administration navigate to Extensions -> Template Manager -> J51_[YourTempate] -> Custom Code and simply paste your tracking code in to the Head Custom Code field, click Save and that's it. It is important to note that if you are using multiple template styles across your site that you repeat this process for each of them.
The second method describes how to add your tracking code directly to your templates index.php file. This method can be used with any Joomla template, in particular if the Custom Code field is not available to you.
- Navigate to Extensions -> Template Manager -> Template -> [YourTemplate] -> Edit main page template
- Source the closing head tag of the template </head>
- Just before the closing </head> paste your Google Analytics tracking code
- Click Save
You have now successfully added the Google Analytics tracking code to your template.