How long did it take to connect to socket io?

Send the duration(in ms) a client waited to connect to a Socket IO instance off to Google Analytics . I use this on PrimaryWall to make sure it’s not taking schools a long time to connect to walls. If I start to see this number getting bigger I know something is going wrong so I have an alert set if the average gets above 1000ms.

This code sends the ms it took from when the document was ready to when the socket was ready.

$(document).ready(function ()
{
  var socketConnectDuration = 0;
  setInterval ( socketConnectDurationIncrease, 100 );  // Start a timer
  socket.on('connect', function ()
  {
    _gaq.push(['_trackEvent', 'Connection duration', 'Connection duration', socketConnectDuration]); // Send the length of time to GA
....
  }
}

function socketConnectDurationIncrease(){
  socketConnectDuration = socketConnectDuration + 100;
}

OWL energy monitor to Google Analytics

I have been able to get my CM160 owl energy monitor to provide data to Google Analytics. This allows me to track energy usage in my house.

It’s disgraceful how bad Owl’s support is for linux users but it’s great to see the community being so active in writing drivers/support to make it a reality.

I have a cron job that runs a php script that sends the data.

I have the Google Analytics PHP Class in the same folder.

The script looks like this:

$file = "/var/log/owl.txt";
$file = escapeshellarg($file); // for the security conscious (should be everyone!)
$line = `tail -n 1 $file`;
$data = explode(" ", $line);
$power = $data[6];
$power = $power*10; // times by 10 so its an integer

include 'autoload.php'; // ga class
use UnitedPrototype\GoogleAnalytics; // use the google analytics class

/* GA Stuff */
// Initilize GA Tracker
$tracker = new GoogleAnalytics\Tracker('UA-34066705-1', 'mclear.co.uk'); // CHANGE THESE SETTINGS

// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress('127.0.0.1');
$visitor->setUserAgent('Slave2');
$visitor->setScreenResolution('1024x768');

// Assemble Session information
// (could also get unserialized from PHP session)
$session = new GoogleAnalytics\Session();

// Assemble Page information
$page = new GoogleAnalytics\Page('/page.html');
$page->setTitle('My Page');

// Track page view
$tracker->trackPageview($page, $session, $visitor);

// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress("127.0.0.1");
$visitor->setUserAgent("slave2");


// Assemble Session information
// (could also get unserialized from PHP session)
$session = new GoogleAnalytics\Session();

// Assemble Page information
$page = new GoogleAnalytics\Page('/statisticsFromTheServer');
$page->setTitle('MySchoolHolidays Server');
/* End GA stuff */

$event = new GoogleAnalytics\Event();
$event->setCategory("power");
$event->setAction("costPerHour");
$event->SetLabel("pence");
$event->SetValue($power);
$event->setNonInteraction("true");
$tracker->trackEVent($event, $session, $visitor);

Your results will take a little while to come through and this can be tested by running the php script. If you don’t get an error then wait 24 hours and see if they come through under Content -> Events in GA

Disclaimer: I did try to use Open Web Analytics to accomplish this but it’s PHP class had an error so I gave up.

Google Analytics Intelligence *new feature

Google Analytics Intelligence allows you set alerts for it something unexpected(or expected) on a site happens. See right for a screenshot.

Intelligence also gives you the ability to do advanced segments. Segments allows you to extend Google analytics to include and/or arguments into your queries. For example you may want to know how many people got to your site by the keyword pizza, but you may also want to know how many of those people were in the city of Bradford. Click below for screenshot.

Educational success in hours per year on a website

One way to look at the success of an educational site is to look at the amount of time in a year spent by users on that site. Below is exactly that.

Total hours since Nov 2,2008:

School Email = 7,806 hours
School Safe Search = 1,894 hours
Primary Games Arena = 1,154 hours
Primary Technology = 771 hours
Primary Blogger = 770 hours
Primary School Teaching (Opened May 2009) = 408 hours
School Closures (Opened Sep 2009) = 84 hours
McLear(My Blog) = 63.7 hours

Thanks to google analytics we can get this information.

I have being able to use this information to explain the real time importance of the sites to their teams. For example if I say to a coder the website has 400 visits a day it doesn’t sound as impressive as if I say..

“The website gives 10 hours of educational help every single day…”

Primary School Teaching has served 2+ hours worth of resources every day, for a website purely built by a community of educators I think our hats go off to teachers for being part of a sharing, web2 community.
Of course if your website is purely designed then a user will struggle to get to the resource they need, we know that isn’t the case here – our users tend to come, find one thing then continue to browse around the site looking for useful resources. Are teachers and learners naturally inquisitive?