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 pages5) Open a blank Notepad, TextEdit or TextMate file. Save as
analyticstracking.php6) 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.