If you have Moodle running on a server with PHP with IIS, you can add detailed statistics with Piwik. While Moodle Statistics are detailed and is capable of giving analytics. Piwik can be used on any website to obtain statistical information.

On IIS, go to Piwik and download their latest release. Extract the file and copy it to your root folder of c:\inetpub\wwwroot. Set permissions to full control with the security table on the extracted folder. For Network and IUSR accounts.
If you are using Microsoft’s SQL, you will need to download MySQL by using the Microsoft Web App Installer. Because you have Moodle up and running, select to install MySQL only. (You should have extracted Piwik and PHP is already running on the server). Follow the installer’s wizard.
Once installed create a table called Piwik with MySQL. At the MySQL command line (found in your program files) type:
CREATE DATABASE Piwik
Remove the ; in front of extension=php_mysqli.dll on the php.ini file. Save the php.ini file. You will need to start and stop IIS.
Follow the installation instructions - http://piwik.org/docs/installation/
Open up the index.php file under your Moodle installation on your webserver. Navigate to the login folder. Open the index.php file to edit it add the following code at the top of your code (this will make javascript run with php).
<html>
<body> Add the code your installation tells you after the body tag (following the installation instructions you will see the code the programmer tells you to put in your website) – This can be done for any of the pages.
Sample below

Piwik gives you very detailed analytics.
Piwik is a downloadable, open source (GPL licensed) real time web analytics software program. It provides you with detailed reports on your website visitors: the search engines and keywords they used, the language they speak, your popular pages… and so much more.
Piwik aims to be an open source alternative to Google Analytics, and is already used on more than 200,000 websites.
Here’s a copy of our previous post on Moodle Stats not working -
Need Statistics to show in Moodle ?
We normally try to put freeware and solutions for all users; however this seems to be a problem with Higher Education that use Moodle.
FIRST – In the Date section in your php.ini file – find the line ;date.timezone =, remove the semi-colon from the front of it and set it to the timezone that you have set in Administration > Locations (In the Moodle Administration Settings). (Mine is America/Chicago). The line in your ini file should look like this date.timezone =’American/Chicago’ . Save the php.ini and the locations set in Moodle under the Server’s time. Restart IIS or Apache.
Go to – Modules | Blocks | Statistics Enter at least 90 days on the graph – Save your settings
Go to – Server | Statistics | Disable Statistics in Moodle |Enter Maximum Processing – All | Enter Maximum Runtime – Until Complete | Enter Days to process 365 | Enter a Run Time 5-20 minutes before your current time on your computer (try to do this when at a Time when the server is not in use or has low usage – I am doing this at 12:40 a.m. – the stat time is at 12:30 a.m.) Go down and Save your Changes! Yes, It is disabled at this point.
On the SQL Server run the following query -
delete from mdl_stats_daily;
delete from mdl_stats_weekly;
delete from mdl_stats_monthly;
delete from mdl_config where name like ‘%stats%’;
Open up Moodle and now Enable Statistics and SAVE
Run cron from the command line – (Windows users, at the command prompt type -
c:\php\php.exe -f C:\inetpub\wwwroot\admin\cron.php
This should have worked…good luck!
No Graph in Stats?
Go to Server | System Paths and make sure you specify GD is installed. You must also take away the ; in front of extension=php_gd2.dll in your php.ini file. If you modify your php.ini, you must restart your webserver.
Like this:
Like Loading...