Mobile app version of vmapp.org
Login or Join
Jennifer507

: Google Analytics in Joomla 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

@Jennifer507

Posted in: #GoogleAnalytics #Joomla

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' );

require_once('layouts/GKTemplate.php');

$Template = new GKTemplate($this);

if($Template->settings["ie6info"] && $Template->IE6Detection())
{
$Template->loadSkeleton("ie6");
}
else
{
$Template->loadBlock("gk_wrapper");
}


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?

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Jennifer507

4 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

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.

10% popularity Vote Up Vote Down


 

@Cody1181609

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.

10% popularity Vote Up Vote Down


 

@Cofer257

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.

10% popularity Vote Up Vote Down


 

@XinRu657

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme