"Helping businesses operate more effectively online"

11

Mar

2008

How to add Google Analytics to Joomla
Written by David Towers   

Joomla Google Analytics Today we're going to answer a very straight forward question that we have been asked: "How can I add Google Analytics to Joomla?"

Google Analytics is a free website tracking tool which helps you understand your website's visitor. We highly recommend it, and in this post will run you through how to add Google Analytics to either Joomla 1.5 or Joomla 1.0.1x.

We have broken down the answer of this question into two steps:

1. Create a Google Analytics account
2. Add the Analytics code to your Joomla template

Create a Google Analytics account

Go to the Google Analytics website and sign up for account.

Once you've followed the registration process you will come to a page where you are given a tracking code to add to each page of your website. If you are given the choice to choose between the new tracking code (ga.js) or the old tracking code (urchin.js) choose the new tracking code.

Keep this webpage open with the tracking code on as we're going to need it in a few minutes.

Add the Analytics tracking code to your Joomla template

Adding the analytics tracking code to your Joomla website is really easy. We're going to show you how to do this through logging in to the administrator backend and editing your template's HTML.

In Joomla 1.0.1x

If you are using Joomla 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14 or 1.0.15 do the following:

  • Log on to: www.yoursite.com/administrator/
  • In the top menu select: "Site" > "Template Manager" > "Site Templates"
  • Then select the template which is marked as default and click "Edit HTML"

In Joomla 1.5

If you are using Joomla 1.5, 1.51 do the following:

  • Log on to: www.yoursite.com/administrator/
  • In the top menu select: "Extensions" > "Template Manager"
  • Now select the template which is marked as default and click "Edit"
  • In the template edit page click "Edit HTML"

Adding the code within the template

If you have followed the steps above you should now be looking at your template's HTML.

  • Scroll right down to the bottom of all this code
  • On the second to bottom line you should see the tag </body>
  • You need to paste your Google Analytics tracking code just before this tag
  • Now press "save" and Google Analytics is installed on your website!

Here is a screenshot of the HTML of a template before we added the Google Analytics code:

Joomla HTML template

And here is the HTML after we added Google Analytics code:

Google Analytics in Joomla

Now you've installed Google Analytics, why not track file downloads automatically using our Google Analytics download tracking Javascript?

We look forward to answering your questions and reading your comments...

97 Comments
0
Rajesh
March 19, 2008
Votes: +16

Hi Nice article.

report abuse
vote down
vote up
David Towers
David T
March 19, 2008
Votes: +4

Thanks Rajesh!

report abuse
vote down
vote up
0
raman
March 27, 2008
Votes: +5

Very simple and effective content about joomla. Will be very useful for budding web masters. Thanks

report abuse
vote down
vote up
0
Prinson
March 30, 2008
Votes: +3

Thanks for your help. I appreciate it very much

report abuse
vote down
vote up
0
Greg
April 08, 2008
Votes: +2

Thank you very much! I originally downloaded a module that supposedly made this process easy. It didn't make it easy, because there was a lack of documentation, and it only supported the legacy mode of Google Analytics.

In contrast, your post was a simple solution. Thanks again!

report abuse
vote down
vote up
0
Javier Giron
April 15, 2008
Votes: +0

i added the code exactly as you said, but it still didnt work.
GA doesnt recognize that the code has been added.
Please advice me what to do.

Thanks!

report abuse
vote down
vote up
0
Tamara
April 16, 2008
Votes: +1

Hi, It takes a day for GA to track info. Try checking tomorrow for your stats

report abuse
vote down
vote up
0
Rob
April 17, 2008
Votes: +8

The next problem, once Analytics was collecting data, was that all of the page names show up in the reports as:
"index.php?option=com_content&view=article&id=126&Itemid=87..."

Hovering over the names in the reports will add the article ID but good luck working out which page that is off the top of your head! smilies/smiley.gif

Is there a way to make Joomla or Google use the Article name or something more friendly in the report?

report abuse
vote down
vote up
David Towers
David T
April 17, 2008
Votes: +0

Thanks for posting Raman, Prinson Greg, Javier, Tamara and Rob!

Javier have your stats appeared yet? Tamara's right, there is usually a lag of about a day.

Rob if you use sh404sef to make your URLs search engine friendly, you won't have this problems anymore. Why not try installing the sh404sef extension on your website?

report abuse
vote down
vote up
0
nitin
June 14, 2008
Votes: +0

thanks the article rocks

report abuse
vote down
vote up
0
Rakesh
July 04, 2008
Votes: +1

Thanks David T,

For Starting such a nice post on Google Analytics, I also installed GA and waiting for a day as said visitors above to detect code by GA.

report abuse
vote down
vote up
0
aa
July 23, 2008
Votes: +1

thank you, great article, very helpfull smilies/wink.gif

report abuse
vote down
vote up
0
ja
July 25, 2008
Votes: +1

Ovo ti je dobar članak lafe. Hvala.
This is good article pal.
Das ist sehr gut Information Kamarad.

report abuse
vote down
vote up
0
sandeep
August 03, 2008
Votes: +1

Thanks.
Its worked perfect on my site.

http://gsmunlock.in

report abuse
vote down
vote up
0
Jenny
August 05, 2008
Votes: +0

Thank you. This is a great article. It helps to all who is new in joomla.

report abuse
vote down
vote up
0
Peter
August 13, 2008
Votes: +0

Thanks. However, the index.php file I have does not have a tag. Not sure where should I insert the GA code if there's no tag.

report abuse
vote down
vote up
0
Peter
August 13, 2008
Votes: +0

I meant to write "/body" tag.

report abuse
vote down
vote up
0
Steogede
August 14, 2008
Votes: -2

I would say it is better to add the GA code directly after the opening body tag, rather than directly before the closing body tag. I know Google say to place the code before the closing body tag, but they don't mean directly before.

The Google help article on tracking links to external sites states that you need to place a call to GA in the onclick attribute. In order for this to work, they say that you must place the GA code before the relevant link - infact they go so far as to say you should put the code between the opening body tag and the a tag which you want to track manually.

report abuse
vote down
vote up
0
Sam
August 23, 2008
Votes: +0

I tried to edit the html file but it was empty. However, I have also index.php file which might cause this. Do you know why I cannot the main index files as you advised?

report abuse
vote down
vote up
0
Zohaib Mir
September 03, 2008
Votes: +1

A good and simple article

report abuse
vote down
vote up
0
rod
September 13, 2008
Votes: +2

Very Thank smilies/grin.gif

report abuse
vote down
vote up
0
Marosh
September 22, 2008
Votes: +0

Hi Guys, nice and simple article.

report abuse
vote down
vote up
0
Al
September 24, 2008
Votes: +0

Since Google Analytics requires the code to be placed on all the website pages. Is it enough to just put the code on the template?
Is there a solution like a plugin that transfers the code in case I change the template?

report abuse
vote down
vote up
Jason Boyette
Jason Boyette
September 25, 2008
Votes: +0

@Al: No, you would need to add it to any template you use. The good thing is that it's only needed in the template, and not EVERY page.

report abuse
vote down
vote up
0
Rob
October 07, 2008
Votes: +0

Is it that easy? Thanks!

report abuse
vote down
vote up
0
John
October 08, 2008
Votes: +0

Thanks,saved me from having to download a module/plugin for my website. smilies/grin.gif

report abuse
vote down
vote up
0
Jim
November 03, 2008
Votes: +0

Thanks, So much it worked perfectly, google is already tracking and it took about on minute, an I'm a new joomla user

Cheers,
Jim Novak

report abuse
vote down
vote up
0
matyus
November 26, 2008
Votes: +0

thanks a lot!!
simple but perfect!! smilies/cheesy.gif

report abuse
vote down
vote up
David Towers
David T
November 28, 2008
Votes: +0

Glad you guys have found it useful!

report abuse
vote down
vote up
0
Alfred
November 29, 2008
Votes: +0

Very helpful. Nice.

report abuse
vote down
vote up
0
Alex Rainy
December 01, 2008
Votes: +0

Tnx a lot!

report abuse
vote down
vote up
0
Pantera
December 12, 2008
Votes: +2

Hi, I did add the code, what I want know is to DISPLAY some of the statistics in the frontpage of my joomla site, also I would like to include a LINK to the complete statistics page.

thanks!

report abuse
vote down
vote up
0
rodrigo
December 21, 2008
Votes: +1

Muito grato pela dica, vou adicionar ao meu site

thanks

report abuse
vote down
vote up
0
jemma
December 30, 2008
Votes: +1

Very simple and effective.

Exactly what i needed. Thanks a lot.

report abuse
vote down
vote up
0
christak
January 07, 2009
Votes: +0

Thank you a lot.
It seems nice.

christak

report abuse
vote down
vote up
0
jack
January 14, 2009
Votes: +1

Thanks a lot for the tutorial it was very helpful.....

report abuse
vote down
vote up
0
Wendy
January 23, 2009
Votes: +0

I have only very recently started to work with Joomla and have found it very confusing. I am slowly suppose to take over a site someone design with Joomla. I am trying to add the analytic codes but your instructions do not match what my menu has. I checked and I am using Joomla Version 1.5.7 Production/stable [Wovusani]. Can you give me any assistance with putting these codes on my site?
Thank you in advance for any and all help.

report abuse
vote down
vote up
0
USN
February 09, 2009
Votes: +1

Great article! Very simple to follow!

report abuse
vote down
vote up
0
David
February 10, 2009
Votes: +1

Nice artlice, Thanks

report abuse
vote down
vote up
0
Christopher
February 13, 2009
Votes: +1

Excellent! Thank you. Took me < 5 minutes.

report abuse
vote down
vote up
0
xboxguy
March 09, 2009
Votes: +0

Thanks for the article. I was going to do just this, but I wanted some confirmation that I had the right idea before possibly crashing my site. Thanks for that confirmation.

report abuse
vote down
vote up
0
Billy Bisco
March 10, 2009
Votes: +0

Thanks for the help

report abuse
vote down
vote up
0
Aniket
March 18, 2009
Votes: +0

Thanks a lot for your help. Just took me less than 5 mins to do a this ....
My client is now very satisfied

report abuse
vote down
vote up
0
Walter
March 21, 2009
Votes: +0

Simple the best! Thanks

report abuse
vote down
vote up
0
fuzzywig
March 29, 2009
Votes: +0

Great article help me out loads thanks

report abuse
vote down
vote up
0
Joe
April 02, 2009
Votes: +0

Excellent article. I've been getting advice on how to add Analytics to Joomla and it hasn't worked, until now. Other persons I've talked with stated I should install a new module and then input the necessary data, which doesn't work. I wasted many hours trying to do it the other way and less than 5 minutes your way.

Thanks,
Joe

report abuse
vote down
vote up
0
Blazej
April 03, 2009
Votes: +0

Thanks! That's really clear and helpful.

report abuse
vote down
vote up
0
dave
April 15, 2009
Votes: +0

thanks! once I read this I was like; duh! I should've known that.

report abuse
vote down
vote up
0
vince
April 16, 2009
Votes: +0

Better than using a module for this. Like the above poster said, "duh! I should've known that". :-)

Thanks

report abuse
vote down
vote up
0
derdave
April 17, 2009
Votes: +0

thx, worked well for me! greetings, der dave

report abuse
vote down
vote up
0
Nel
April 22, 2009
Votes: +0

coo As Easy as posibel

report abuse
vote down
vote up
0
Earn Money Writing
April 22, 2009
Votes: +1

Thanks for the article.

I will test it out and hopefully it works.

report abuse
vote down
vote up
0
Conken
April 23, 2009
Votes: +0

Champion effort Sir.

Thank you.

report abuse
vote down
vote up
0
Ashley
April 28, 2009
Votes: +0

Thanks Man For this wonderful Article Its working Great....
God Bless you

report abuse
vote down
vote up
0
Howard
April 28, 2009
Votes: +0

Thank you!

report abuse
vote down
vote up
0
Keith
April 28, 2009
Votes: +0

Sometime its great to go in the old fashioned way under the hood without a plugin and mae things happen.

Today, thanks to you, it was the easiest task of my day.

Thanks muchly.

report abuse
vote down
vote up
0
name
April 29, 2009
Votes: +0

Excellent thankyou so much --- this is what is good about the net

report abuse
vote down
vote up
0
Allyson
May 01, 2009
Votes: +0

Ditto!
Previously I tried using a module, but why bother? This is so easy.

report abuse
vote down
vote up
0
gilles
May 08, 2009
Votes: +0

Perfect!

wonderful/clear instructions!

Thanks so much!

report abuse
vote down
vote up
0
Joan
May 13, 2009
Votes: +0

Nice and clear. Great article!!!
Thanks

report abuse
vote down
vote up
0
synoptik
May 15, 2009
Votes: +0

hi, i just don't understand s/thing. the google tutorial says that i should see the tracking code in a web browser (developer -> html code). i've inserted the code in the template in the way described above but i don't see it there. so i'll wait till the next morning and see if it works.

in other hand the article is written very clearly so even a beginner can follow. thank you.

report abuse
vote down
vote up
0
G. Tsolakis
May 27, 2009
Votes: +0

thank you so much

report abuse
vote down
vote up
0
Andy
May 29, 2009
Votes: +0

For some reason "Template Manager" does not show up under my Extensions menu. I only have "Install/Uninstall", "Module Manager", and "Plugin Manager". Do you know why this isn't showing up or how I can get around it to ad Google Analytics. I'm using version 1.5.3 of Joomla.

report abuse
vote down
vote up
0
softlogic
May 29, 2009
Votes: +0

thanks for a clear article

report abuse
vote down
vote up
0
Andy
May 29, 2009
Votes: +0

I figured out why my "Template Manager" was not showing up. I was not logged in as a Super Administrator, only as an Administrator. I had someone else create the site originally and he did not convey the Super Admin login info to me.

report abuse
vote down
vote up
0
schnell abnehmen
June 03, 2009
Votes: +0

It worked with me. I used to add the Analytics script to the index.php when using Joomla 1.x. For some reason, it didn´t work this way in Joomla 1.5 so I went for your solution.
Tx.

report abuse
vote down
vote up
0
Martin
June 04, 2009
Votes: +0

Excellent article which made adding Google Analytics dead simple, there should be a link to this from Google Analytics.
Very much appreciated.

report abuse
vote down
vote up
0
San Francisco
July 07, 2009
Votes: +0

Any updates or advice on conversion tracking for an e-commerce store using VirtueMart/Joomla? Is there a way to have a 'thank you' page generate after each sales process is confirmed? Trying to figure out how to determine what URL to use to monitors goals.

Thanks.

report abuse
vote down
vote up
0
yuk
July 17, 2009
Votes: +0

thank you very much

report abuse
vote down
vote up
0
Jeff
July 17, 2009
Votes: +0

Awesome writeup - had the Google Analyitics code on my site in just a couple of minutes. Like others, I was just about to download a plugin, this is WAY easier.

Now to wait for the stats to be 'posted' on Google. ;-)

Thanks again!

Jeff

report abuse
vote down
vote up
0
Auto Man
July 22, 2009
Votes: +0

I thought that you are going to mention a plugin to do the work for us, but this is even better! Thanks!

report abuse
vote down
vote up
0
siegfried
July 23, 2009
Votes: +0

Awesome. Just what I needed.

Thanks

report abuse
vote down
vote up
0
Dennis van Leeuwen
August 09, 2009
Votes: +0

Will adding my GA code to the template be enough for tracking virtuemart (which is installed) information also? Or do I need to ad the code to the Virtuemart component also?

report abuse
vote down
vote up
0
John
August 12, 2009
Votes: +0

I think I must be missing something. I followed the steps and everything seems to work. However, the content tracking in Google Analytics shows the visited content in the following format.

/public/index.php?option=com_content&view=section&layout=blog&id=1&Itemid=3

Being new to Joomla, I am not sure how to map this to my website. I assume the "id" is the id of the section. Is the "Itemid' the id of the article?

It would be great if there was a way to have the content via the section or category alias rather than the id.

Thanks

report abuse
vote down
vote up
0
iain
September 01, 2009
Votes: +0

Thanks for the tutorial.

I couldn't add the code through the template manager... kept saying that the php file couldn't be opened for editing.

Instead, I accessed the php file through ftp and edited it in wordpad...

report abuse
vote down
vote up
0
Tony
September 04, 2009
Votes: +0

Thank you for this article - you saved my site! Placing this script before the body, is fatal. Your tip works A1.

report abuse
vote down
vote up
0
Accounting Teacher
September 11, 2009
Votes: +0

It is extremely easy, I was planning to incorporate an extension, but it can be done without it. And You showed it how.

report abuse
vote down
vote up
0
Miguel Garcia
September 18, 2009
Votes: +0

Hi...

Simply excellent. Superb...

Any way I need to repost Dennis van Leeuwen Question:

Will adding my GA code to the template be enough for tracking virtuemart (which is installed) information also? Or do I need to ad the code to the Virtuemart component also?

Lots of Thanks David Towers

Great article...

report abuse
vote down
vote up
0
TimM
September 21, 2009
Votes: +0

I have added the code as described and have an icon on the GA panel indicating that the web site is not being tracked. Does this mean that the process has not worked or does this mean that the process worked and GA has not yet updated? I have tried to save and refresh but it makes no difference.

Grateful of any advice

report abuse
vote down
vote up
0
Academic Blog
September 23, 2009
Votes: +0

Hey, thanks for the help!! I just added analytics to my joomla template.

report abuse
vote down
vote up
0
justin
September 26, 2009
Votes: +0

Same doubt as someone else above,is it enough to just paste the tracking code by edit the template page?as GA requires the codes on every page.

report abuse
vote down
vote up
0
Angie
October 21, 2009
Votes: +0

Nice tutoril, appreciate it. But would like to know how to track information in VirtueMart. Any input would be appreciated.

report abuse
vote down
vote up
0
Nikki
October 24, 2009
Votes: +0

Fantastic, couldn't have is explained it more clearly, great job smilies/smiley.gif

report abuse
vote down
vote up
0
DrMistry
November 11, 2009
Votes: +1

Good job - short, sweet and accurate. Thanks for posting.

report abuse
vote down
vote up
0
July
November 12, 2009
Votes: +0

Thank you!
I searched about Google Analistic+Joomla 1.0 - and your topic answer, how i can do this!

report abuse
vote down
vote up
0
pojisteni
November 28, 2009
Votes: +0

Hi, is it possible to have GA only at one main site and meassure accesses from another subdomains? Or is it necessary to have unique GA on each subdomain?

report abuse
vote down
vote up
0
Miguel J. Parias
December 01, 2009
Votes: +1

Hi all,

I have joomla 1.5.15. When I go to edit HTML, the file is "empty". I read somebody used other technic to edit the index.php file. Can somebody tell me how to do it? Thanks in advance,

MP

report abuse
vote down
vote up
0
C
December 02, 2009
Votes: +0

is not working in my site.

what am i missing ?

report abuse
vote down
vote up
0
Julia
December 12, 2009
Votes: +0

Same here my file is empty....any suggestions?

report abuse
vote down
vote up
0
dawn
December 13, 2009
Votes: +0

Thanks - great article.

report abuse
vote down
vote up
0
Jericho
December 19, 2009
Votes: +0

Not working with my site either (1.5.15). When I add the code, the pages of my site don't want to display. All i get are empty white pages.

report abuse
vote down
vote up
0
Jason
January 09, 2010
Votes: +0

using Joomla 1.5.15 and Rhu-Milkyway template..I added the analytics code immediately before the /body tag, and it shows up on every page if you viewsource. No problems with page loading. I will wait a day and look for data, but this isn't my first time using analytics so I am sure it will work.

report abuse
vote down
vote up
0
Jason
January 09, 2010
Votes: +0

As an update to the above...in Google Analytics, sometimes it takes a while for the little yellow yield triangle status symbol to go away. You can manually force google to look for the code by clicking on "edit" at the end of the row. Then on the new page, at the upper right hand corner of the table is a small link that says "check status". Click "check status" and the new page should tell you immediately if the code is installed correctly.

report abuse
vote down
vote up
0
Web Design Kent
January 15, 2010
Votes: +0

Great info. Just what I need to convert my static site to Joomla and keep my tracking stats.

report abuse
vote down
vote up
0
Devin
January 17, 2010
Votes: +0

amazing, your article is very helpful. Thanks.

report abuse
vote down
vote up
0
MikeT
January 22, 2010
Votes: +1

Awesome! Thank you!

report abuse
vote down
vote up
0
Specusphere
January 28, 2010
Votes: +0

Beautiful, thanks for the help! Really appreciate it. Those were very clear and relevant instructions.

report abuse
vote down
vote up

Write comment
 
  smaller | bigger
 

busy