Google analytics: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 25: Line 25:
In the past, I edited the skin files and place the "old" Google code just before the </body> tag.
In the past, I edited the skin files and place the "old" Google code just before the </body> tag.


We now use the following simple extension code found in [http://www.mediawiki.org/wiki/Extension_talk:Google_Analytics_Integration Extension talk:Google Analytics Integration] page at Mediawiki.
We now use extension code (makes updating easier for example). Currently, for MW release 1.16.4, we use the following simple extension code found in [http://www.mediawiki.org/wiki/Extension_talk:Google_Analytics_Integration Extension talk:Google Analytics Integration] page at Mediawiki. Its author is unkown.  


 
File 'extensions/GoogleAnalytics.php' (change "UA-xxxxxx-x" to your own key):
File 'extensions/GoogleAnalytics.php':
<source lang="php">
<source lang="php">
<?php
<?php

Revision as of 12:58, 22 April 2011

Draft

Google analytics is a a google services that allows insights into website traffic with Advanced Segmentation, Custom Reporting, Motion Charts, and more.

See also

  • Google webmaster tools which gives you very different information, i.e. its data is based on the google search engine.
  • Google website optimizer which allows to create so-called A/B or multivariate tests (i.e. some kind of light-weight quasi-experimental playing with variants of landing pages)

Tool overview

The services includes several groups of tools, e.g.

  • Visitors
  • Traffic Sources
  • Content
  • Goals

How to

  • Get a Google account and sign up to analytics
  • Modify all your web pages to include a javascript fragment


A simple Mediawiki extension

In the past, I edited the skin files and place the "old" Google code just before the </body> tag.

We now use extension code (makes updating easier for example). Currently, for MW release 1.16.4, we use the following simple extension code found in Extension talk:Google Analytics Integration page at Mediawiki. Its author is unkown.

File 'extensions/GoogleAnalytics.php' (change "UA-xxxxxx-x" to your own key):

<?php
global $wgGoogleAnalytics;
$wgGoogleAnalytics = false;

$wgHooks['ParserAfterTidy'][]  = 'efGoogleAnalytics';

function efGoogleAnalytics() {
	global $wgOut;
	global $wgGoogleAnalytics;

	if (!$wgGoogleAnalytics) {
		$funcOutput = <<<GASCRIPT
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script>
GASCRIPT;
		$wgOut->addScript($funcOutput);
		$wgGoogleAnalytics = true;
	}
	return true;
}
?>

Add in LocalSettings.php:

require_once($IP.'/extensions/GoogleAnalytics.php');

Links

At Google
Videos made by Google

There are many videos about Google Analytics. A good short list of videos is [http://www.squidoo.com/ultimate-google-analytics-guide The Ultimate Google Analytics Video Guide

Introductions