Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was asked by a client to insert the Google Analytics code in his joomla page. No problem, I said, peace of cake.

Little did I know that it is going to be such a struggle.

First of all, I downloaded the active template and searched through code and couldn't find any HTML except about 20 index.html pages with only: <html><body bgcolor="#FFFFFF"></body></html>.

Now I tired editing through Joomla and when the index page opens and I click edit the HTML, it's all PHP.

defined( '_JEXEC' ) or die( 'Restricted access' );


$Template = new GKTemplate($this);

if($Template->settings["ie6info"] && $Template->IE6Detection())

I'm not too good with PHP, I'm more of a Asp.net kinda guy, so I don't understand this code, but where is the <head> tag in which I'm supposed to insert the Google Analytics code snippet?

share|improve this question
up vote 2 down vote accepted

Have a look at the J!Analytics plug-in (to reverse-engineer it ... or simply install it)

share|improve this answer

In the included file layouts/GKTemplate.php there will be some functions loadSkeleton and loadBlock which may have the code you require. Though they could easily be calling other functions and so on.

If you have a way to search through multiple files (Notepad++ can do this) search for <head> to find where to put the code.

share|improve this answer

This is very simple, you just need to know where to look.

In the template for the site there exists an index.php file. Put the Google Analytics's JavaScript in the head tag near the top.

share|improve this answer

You don't need to edit actual files at all. Go into your site's administrator interface, then go to Extensions-->Template Manager. Click on the template name, and then the Edit HTML button. It will open the site's main framework, which all other code opens in. Just add the analytics javascript at the very bottom, still inside the body tag.

share|improve this answer
That won't work - all it does is let you edit the index.php file, which obviously is not a standard one based on what the OP has said. – DisgruntledGoat Nov 4 '10 at 20:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.