Google Analytics code

Advanced newspaper or magazine Joomla template to build news website with unique and detailed design.
GK User
Thu May 13, 2010 10:17 am
Hi,
I would like to know where to insert the google analytics code:

I checked in the template directory and I saw that the index.php has a quite different structure, so I have a doubt where to insert that code.


with thanks
User avatar
Fresh Boarder

GK User
Thu May 13, 2010 10:24 am
you have to put it and end of the template body element - you can find it layouts/blocks/gk_wrapper.php file.
User avatar
Administrator

GK User
Fri May 14, 2010 8:49 pm
This seems unnecessarily complex, and should be made easier.

Some template companies make it easy to insert analytics code in their template configuration system.

Will Gavick consider doing the same?

Thanks,
Ken
User avatar
Junior Boarder

GK User
Fri May 14, 2010 8:52 pm
Corroborating my last post, my folder templates/gk_memovie/layouts/blocks doesn't have gk_wrapper.php

My TWN temlplate has that file. Perhaps that's the right answer for Pre-T3 templates, but not for T3 templates?

Is it somewhere else in T3?

Thanks,
K
User avatar
Junior Boarder

GK User
Sat May 15, 2010 12:35 am
in memovie it is file layouts/default.php
User avatar
Administrator

GK User
Wed May 19, 2010 10:24 pm
In the default.php file, there are two </body> tags. Before which tag should I copy and paste the analytics code? Looks like it should be both. Is that right?

Additionally, should I copy the code into the iphone and handheld templates as well? And set up additional, separate Google Analytics tracking data (so I can see how my mobile website compares with the browser version)?
User avatar
Expert Boarder

GK User
Fri May 21, 2010 1:08 am
Yes in both, because second body tag is used in IE6 template. For every layout you should do the same, because only then all visits will be counted.
User avatar
Administrator

GK User
Fri May 21, 2010 4:55 am
Check some good extensions to do that out of the box. http://extensions.joomla.org/extensions/site-management/site-analytics
User avatar
Senior Boarder

GK User
Fri May 21, 2010 9:19 pm
Thanks for the feedback guys. I put it at the end of both </body> tags and it worked.
:)
User avatar
Expert Boarder

GK User
Wed Jun 02, 2010 12:31 pm
thanks for this, I wondered too!
User avatar
Fresh Boarder

GK User
Thu Jun 03, 2010 9:38 pm
I use the memovie, and i read the replies from spanners, still not working for me, i still get the yellow exclamtion-mark in analtics [!] please some help...
User avatar
Fresh Boarder

GK User
Fri Jun 04, 2010 12:35 am
please show us your website.
User avatar
Administrator

GK User
Sat Jun 05, 2010 9:43 am
nevermind, (a had to be patient ;) after 1 day it's shows up fine.
User avatar
Fresh Boarder

GK User
Sat Oct 02, 2010 10:21 am
google are saying that the analytics code should be inserted in the <head> metatags!

which template file should i modify to have the code appear in the <head> metatags?
User avatar
Fresh Boarder

teitbite
Sat Oct 02, 2010 11:11 pm
Hi

layout/blocks/head.php
User avatar
Moderator

GK User
Mon Feb 21, 2011 4:52 am
We've done some major updates to our websites and we're re-adding the tracking.

Just so people who come to this thread know, you can select the Advanced tab in the Tracking Code section.

I've ticked I want to track PHP pages.

This brings up some slightly different instructions. I've created a PHP file called analyticstracking.php and I've copied and pasted in the code.

Then I add immediately after the <body> tags in layout/default.php on line 227, I've added...
Code: Select all
<?php include_once("analyticstracking.php") ?>


Gavick Guys: Is this correct?
User avatar
Expert Boarder

teitbite
Mon Feb 21, 2011 9:08 pm
Hi

File is being added propperly but what is in this file ? It's a different story :D
User avatar
Moderator

GK User
Tue Feb 22, 2011 11:01 pm
This is what the Google Analytics website says...

For any PHP pages, put the following code in a file (for example, analyticstracking.php) and upload it to your site. Then, add the following line to each template page immediately after the opening <body> tag: <?php include_once("analyticstracking.php") ?>

This is what the code looks like, but DON'T COPY THIS. You'll need to copy the code from your own Analytics account.

Code: Select all
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '**YOUR UA NUMBER HERE**']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>


If you are like me and already have standard tracking, not the PHP tracking, then this is how you update to the advanced, PHP tracking with a specific PHP file.

1) Log into Google Analytics
2) Click EDIT next to the website you wish to update tracking (right hand side of table)
3) Top right of the screen you'll see a little green tick next to Receiving Status (provided you're already got tracking enables). Click Check Status
4) Under Instructions for Tracking, click the Advanced tab, and under that tick I want to track PHP pages
5) Open a blank Notepad, TextEdit or TextMate file. Save as analyticstracking.php
6) Copy the provided code into blank file you just created
7) Save this file locally and then upload your analyticstracking.php file into template/gk_[TEMPLATENAME]/layouts (same folder as default.php)
8) Download and open default.php in that same folder you just uploaded analyticstracking.php and save a copy as a backup in case you get it wrong (eg. default-[DATE].php)
9) Open the default.php file again in your text editor and do a search for <body (yes, angle-bracket body - it's line 227 on the GK Memovie template)
10) Paste the following code on the next blank line
Code: Select all
<?php include_once("analyticstracking.php") ?>

11) Save and upload back into the layouts folder over the top of the previous default.php file

Your new Google tracking won't be working straight away, so check back in a few hours to make sure it says its still tracking. Look for that same green tick.

Hope this helps someone out there.
User avatar
Expert Boarder

teitbite
Thu Feb 24, 2011 1:06 am
Hi

For sure it will help :) Thank You for that.
User avatar
Moderator


cron