Wednesday, February 13, 2013

Adding google analytics to my moodle site

I am adding Google Analytics to my recently minted moodle site.  I browsed to my Google Analytics accounts page and created a new site to track. 

Google Analytics home page.

After naming the site, providing the URL and agreeing to the policy, I was presented with the familiar tracking code.  In the past, I have copied the tracking code directly into the footer of one of the layout files in the theme.

Today, I noticed a nice new option.

The new option was to save the tracking code into a php file and then include it in the site page.  This seems more clear to me that dealing with the footer in a theme.

I saved the tracking code into a file called analyticsTracking.php and then included it in the top of my site index.php file.

Require_once('analyticsTracking.php ');

I tested that it was reading the file by sticking an alert('test') line in the analyticsTracking.php file.  When I refreshed the home page of the moodle site, I saw the javascript alert message.  Good enough for me!










I will check the reporting on the account tomorrow.

No comments:

Post a Comment