5 Reasons to use Piwik with Moodle

Are you using Google Analytics for compiling useful Moodle data?  Have you considered using Piwik?

Piwik is an Open Source (self-hosted) alternative to Google Analytics, and it’s pretty awesome.  The feature list speaks for itself, but why would we want to go through the hassle of installing it on a server, updating it and looking after it when you may already be using Google?

Here are my top 5 reasons for choosing Piwik over Google Analytics with Moodle:

1) Improved page load times
I have often found that using Google Analytics on any website can sometimes increase the page load time as we are often waiting for the response from the analytics server.  This is more apparent in educational establishments as traffic is pushed through firewalls and student content filters.  Hosting Piwik yourself, ideally on the same Moodle server is considerably faster.

Hosting Piwik yourself, ideally on the same Moodle server is considerably faster.

2)Track downloads
Piwik tracks downloaded files, Google Analytics doesn’t.  And considering Moodle is often “repository” based this is a killer feature.  We get to see the file name and how many downloads it had, and we can search within date ranges.  The naming of the returned file isn’t great but it’s easy to figure out what file was downloaded.

Piwik Moodle File Downloads3) Outbound link tracking
Piwik tracks the number of outbound links (links to external websites).  Especially useful within Moodle as we want to keep users in Moodle where possible and encourage the embedding of resources. When we take students away from Moodle it’s hard to get them back (we’ve all done it, I get lost on IMDB for hours sometimes).  With Piwik we can see where our students go after they leave a course.  And hopefully we can plug these holes so they stay on Moodle (forever!)

4) Funky exports
I love the way that Piwik exports data and the formats which we can export in.  It seems very intuitive and simple and you can put some of this data back into Moodle or any custom tools you have.

Piwik ExportFor example, you can grab the RSS feed for your Moodle Downloads and republish them in a Moodle course RSS Block so tutors can see what is happening without having access to Piwik.  For the more techie amongst us we can export using JSON and XML so we can integrate the data with some custom PHP programming or even mobile apps.

5) Create custom dashboards to track distance learners, out-of-hours learners, weekend learners and more. 
OK, this is a feature of Google Analytics too, but I just prefer the way it’s laid out in Piwik.
We can track what times of the day students access Moodle and then compare this against the course/page list.  At last, we get to see how Moodle is used at weekends, on what device and what the students did on the site.

We can also create custom dashboards.  Why not create custom dashboards for different groups of users in your organisation?  For example, why not create a dashboard for your marketing department that shows how your users found your Moodle site?  And then create a dashboard for enrollments that uses goals to track how many visitors became actual learners and enrolled on a course?  And finally a dashboard for tutors that shows learner devices and access times?

Piwik Mobile Use

Custom dashboards are great, they simplify the user experience and get you the data you need.

Extend the usage of your analytical data in Moodle

Once you have installed Piwik and collected several weeks of data then you are ready to turn this data into something meaningful.
After all, Moodle has some excellent reporting features, but these are focused at course level, whereas Pwik is more site level.

Use Goals
Goals are intended for eCommerce sites, where we can track a user journey on the site and see how much the user spent as a result of  that single visit.  But in Moodle, by tracking self enrollment or PayPal enrollments,  we can use goals in a similar vain.  Either for monetary analysis or good old fashioned plain curiosity.

A simple goal could be user registration.  We can setup a goal that triggers when a user registers on the site.  By selecting the registration page as the given URL we can track guests that convert to actual learners.

We can assign goals to course enrollments so data is captured when a student self-enrolls on a course.  Again this data can be exported and used in your reports.  And can be converted to monetary values if required.

Student Engagement

One of the things many organisations ask me is “How long are students spending on the Moodle site?”  Well although we can’t drill this down on a per user basis we can generate some interesting site wide numbers.  By using the “Page Titles” report we can see an average time that each student spends visiting a course.  Are they logging on, grabbing a document and logging off (see bounce rates) or are they accessing a course and staying there?  This is all useful data that helps you shape a great engaging Moodle course.

Page titles and visit duration

Give Piwik a  go today, it doesn’t take long to install and the insight it gives you is incredible. It’s free, it’s open-source and very clever.

Upgrading Moodle from 2.1 to 2.5 using command line and automated batch files

This summer I am undertaking a huge Moodle upgrade.  We are actually moving up 4 versions in one go.  But as you are already aware, you can’t simply upgrade from 2.1 to 2.5 in one step.  And the processes involved to get that far are tedious and time consuming.  So I have a solution to make the upgrade as simple and as seamless as possible, and that’s to use command line and a clever batch file.

Batch Files Moodle

Batch files- it takes you back to the 90s, in a good way!

So let’s take a look at what’s involved without using command line upgrades and batch files.
To upgrade Moodle from 2.1 we would have to do the following:

  1. Backup the DB
  2. Delete the contents of the webfolder leaving the config.php
  3. Copy the 2.2 files across
  4. Login to the site and run the upgrade page and sit through the upgrade process
  5. Whilst crossing your fingers and praying the server doesn’t time out.

And then once this is done, you repeat the process for 2.3, then for 2.4, and then for 2.5.  This would take huge amounts of time, and most likely time out and requires you to be sat there watching..waiting..stressing!

Command Line
Upgrading Moodle from the command line is always recommended, it won’t time out and is much safer and faster.  But we’d still need to delete files, copy files and keep track of everything.  The solution to this is to create a batch file that triggers all the commands sequentially and completes the steps for us.

The Solution

Windows batch files are so easy to create using a text editor like notepad.  Each command is on its own line and the whole thing is relatively painless.  We begin by dumping the current database to an SQL backup file in case we break things.

We need to create a folder on our server with all the various Moodle versions in separate folders, along with our custom stuff.  So it looks something like this:

Windows Explorer showing custom files

Windows Explorer showing custom files

In this folder (called upgrade) I have the Moodle 2.2 files, the 2.3 files, 2.4 and 2.5 respectively.  I also have a copy of my Moodle config.php file in a folder called config (I’ll need to keep copying this across before each upgrade when I wipe the folder contents).  All my custom code and third party blocks and modules are in the custom folder and follow the same file structure as Moodle.

So we create a file called “moodleupgrade.bat” and with a text editor begin to write DOS commands. The first command is the most important – BACK IT UP!

ECHO Moodle Upgrade Batch script thingymysql --user=root --password=******* > moodle.sql

Now we need to clear the contents of the webroot and copy the Moodle 2.2 files across.
We use Robocopy for this because RoboCopy is awesome , it’s fast, it’s built into Windows and it can mirror folders and directories (thus wiping them).

robocopy c:\upgrade\moodle22 c:\sites\lcmvletest\public_html /MIR
robocopy c:\upgrade\moodle22 c:\sites\lcmvletest\public_html config.php

We have now copied all the files ready to upgrade, we now need to run the Moodle upgrade script from command line.  And because we don’t want to have to enter Yes when asked, we want it to be automatic we prefix the command with that key stroke

cd PHP
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php
Moodle Batch file upgrade

Command line, your old new best friend

We then repeat the process for all the other versions.  Lastly we add our custom blocks and third party blocks by using Robocopy and the upgrade script from DOS.
And it’s as easy as that.  The hardest part is remebering where all your files are making sure you have all the files required for the upgrade.

The full script I use is found below.  It currently takes 45 minutes to run through and upgrade Moodle from 2.1 to 2.5 with all the modules and blocks in place.

And the best thing is, it is purely automated, no user input required and it can be set as a scheduled Windows tasks so you could tell it to trigger in the early hours of the morning for you to wake up to.  But I’m not that brave, I would prefer to watch it on screen as it happens.

I hope you find this useful.

ECHO Moodle Upgrade Automation
mysql --user=root --password=******** moodle > moodle.sql

robocopy c:\upgrade\moodle22 c:\sites\lcmvletest\public_html /MIR

ECHO Now putting config.php back in
robocopy c:\upgrade\config c:\sites\lcmvletest\public_html config.php
ECHO Files copied, now running upgrade script
cd PHP

ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 
ECHO Upgrade to 2.2 complete, now copying files for 2.3

ECHO Copying 2.3 files...
robocopy c:\upgrade\moodle23 c:\sites\lcmvletest\public_html /MIR
ECHO Now putting config.php back in
robocopy c:\upgrade\config c:\sites\lcmvletest\public_html config.php

ECHO Now let's upgrade to 2.3...
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 
ECHO Upgrade to 2.3 complete, now copying files for 2.4

ECHO Copying 2.4 files...
robocopy c:\upgrade\moodle24 c:\sites\lcmvletest\public_html /MIR
ECHO Now putting config.php back in
robocopy c:\upgrade\config c:\sites\lcmvletest\public_html config.php

ECHO Now let's upgrade to 2.4...
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 
ECHO Upgrade to 2.4 complete, now copying files for 2.5

ECHO Copying 2.5 files...
robocopy c:\upgrade\moodle25 c:\sites\lcmvletest\public_html /MIR
ECHO Now putting config.php back in
robocopy c:\upgrade\config c:\sites\lcmvletest\public_html config.php

ECHO Now let's upgrade to 2.5...
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 

ECHO now copying database enrol tweaks
robocopy c:\upgrade\custom\database c:\sites\lcmvletest\public_html\enrol\database /MIR

ECHO now copying custom blocks
robocopy c:\upgrade\custom\blocks c:\sites\lcmvletest\public_html\blocks /s
ECHO Now run upgrade script to install blocks
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 

ECHO Blocks done, now copying custom mods
robocopy c:\upgrade\custom\mod c:\sites\lcmvletest\public_html\mod /s
ECHO Now run upgrade script to install mods...
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php 

ECHO mods complete, now copying custom local plugins
robocopy c:\upgrade\custom\local c:\sites\lcmvletest\public_html\local /s
ECHO Now run upgrade script to install custom local plugins
ECHO y|php.exe c:\sites\lcmvletest\public_html\admin\cli\upgrade.php