Gaug.es is a really nice looking analytics platform as an alternative to Google Analytics. It is a paid service, but not that expensive really.
We’ve made an R package to interact with the Gaug.es API called rgauges. Find it on Github and on CRAN.
Although working with the Gaug.es API is nice and easy, they don’t keep hourly visit stats and provide those via the API, so that you have to continually collect them yourself if you want them. That’s what I have done for my own website.
It took a few steps to get this data:
I wrote a little Ruby script using Twelve gem to collect data from the Gaug.es API every day at the same time, which just gets the patst 24 hours of data. This script makes a call to the Gaug.es API and sends the data to a CouchDB database hosted on Cloudant. In reality, the script is is embeded in a rack app as I don’t think you can throw up a standalone script to Heroku. Here’s the script:
One little catch though: I run the Ruby script on Heroku, so I don’t have to do it locally, but Heroku free instance goes down unless it’s doing something. So I used a little service called UptimeRobot to ping the Heroku app every 5 minutes. UptimeRobot also is giving you uptime stats too on your app, which I don’t really need, but is a cool feature.
And that’s it. Now the data is stored from each day’s collection of visitor stats to a free Cloudant CouchDB database.
Regular Gaug.es data
First, let’s look at what you can do with data that Gaug.es does give to you, using the rgauges R package.
Load rgauges and other dependency libraries
Visualize traffic data
You’ll need to load ggplot2
Historic hourly Gaug.es data
Now let’s play with the hourly data. To do that we aren’t going to use rgauges, but rather call the Cloudant API. CouchDB provides a RESTful API out of the box, so we can do a call like https://app16517180.heroku.cloudant.com/gaugesdb_scott/_all_docs?limit=20 to get metadata (or other calls to get the documents themselves). (note: that url won’t work for you since you don’t have my login info)
Get some data
Manipulate and visualize
So we’ve got 198 days of data, first collected near end of June, and most recent yesterday. Now get actual visits data
We need to combine the date and hour in to one date time string: