As a Joomla developer, you may run across the need to add Google Analytics to a Joomla website, either you want to monitor your own analytics or you have a client that you can track their visitors. Either way, you will have to know how to add the Google analytics code to your Joomla site.
The most important part of adding Google analytics code, is finding where to put the code so that it will appear on every page of the site. This is reliably easy, but it does require you to understand how to modify the HTML of the default template in the administration section of your Joomla installation.
The first thing you will need is an account with Google. This article assumes that you already have an account set up with them and know how to access the code that will be added to your site. Once you have logged in to your account, copy all of your Google Analytics tracking code. Paste it in a text program and save for future reference.
Next, login to the administrator area of your site. Go to Extensions> Template Manager. Select your default template's check box and then click "Edit". In the template edit page, click "Edit HTML". This shows you your template's index.php page. Select all of the text, copy it and then paste this into a text program which you should save in a safe place in case you do any damage to the original document.
Now, go back to the original file, and scroll down to the bottom of the page. The second to the bottom line should have the end body tag which looks like a forward slash followed immediately by the word "body". Paste your code just BEFORE the end body tag. Click "Save".
You have now placed the Google Analytics code on every page of your Joomla site. Keep in mind that if you change templates, you will need to add this code, using the same procedure, to your new template.