Tracking your dog with GPS and Google Universal Analytics

After posting on Google+ about my blog post on the measurement of offline stores with Google Universal Analytics, I got a dare by user Damion Brown from Melbourne, Australia, to track what his dog was doing using a similar method.

Damion: I’m sorry, mate. I’m afraid I have bad news and good news.

  • The bad news is: I don’t own a dog so I’m not sure as to what I’d want to track.
  • The good news is: I can give you pointers on how to do it. I have done enough tinkering in the last 2 weeks so I’ll let by blog readers do it this time around. You guys get to test (and prove) the concept yourself!

In this experiment, you will attempt the following: track your dog’s location (in 5 minute increments), in relationship to your house, with Google Universal Analytics.

I have a few ideas about that and I’ll be sharing them after the jump.

The concept

This suggestion is a bit more high-tech than the previous proof-of-concept project.

This concept involves dog collars, 3G and satellites. Not the kick-ass tag management solution, I’m talking about those things that clutter the Earth’s lower orbit.

Yes, i’m talking about tracking your dog with a GPS-enabled collar via Google Analytics over 3G (phew).

My suggested process involves the following steps:

Step 1: Define your location

Using your GPS-enabled smartphone and determine the GPS coordinates for your humble abode.
Mine is Lat. 44.5406233, Long. 4.7618274 give or take a couple meters for precision. If not sure, use a street address-based GPS location website such as http://www.whatsmygps.com/.

Step 2: Pimp your doggie

Now let’s bring in my imaginary dog. I call him Sparky because the poor thing has no hind legs and balls of steel.

Now we need to give Sparky superpowers of measurement. Let’s go shopping!

You’re probably going to need the following items:

You’ll need the GPS chip to gather your dog’s location and the 3G dongle to communicate with the Google Analytics mothership. On the software side of things, you will need a GPS server and client (gpsd).

Hack this all together. Your turn to be creative. Now hang this to your dog’s collar on in one of those fancy doggie backpacks. Sparky should be ready to be released into the wild (your backyard) to measure and report his position.

Step 3: Who let the dog out?

Now we need to ping your GPS every so often and it should return a set of coordinates with latitude and longitude. Ironically for Google Analytics tracking of your dog’s pimped-out GPS 3G collar, the alternative system for lat/long coordinates is called… *drumroll*… UTM 😀

The GPS client you installed on your Raspberry Pi should return the coordinates for you. It looks like it has a Python API. Heck, it will even give you a JSON feed!

Now apply a bit of math to calculate the distance between your home’s GPS coordinates and your dog’s current coordinates. Store that value in a Python variable, determine the direction from your home (N, S, E, W, etc.) and get ready for doggie to phone home.

Step 4: Sending data to Google Universal Analytics

Using the same method I used for PDF tracking with Google Universal Analytics, let’s define our UA endpoint:

http://www.google-analytics.com/collect<br />?v=1 // site/app version<br />&amp;t=event // GA hit type (event here)<br />&amp;tid=UA-7634164-5 // GA profile ID<br />&amp;cid=555 // anonymous visitor ID<br />&amp;ec=DoggyTrack // Event - Category<br />&amp;ea=Ping // Event - Action<br />&amp;el=SW // Event - Label<br />&amp;ev=12  // Event - Value - Distance from home

Now let’s call this endpoint on a regular basis, every few seconds or so – matching the GPS requests – using wget:

wget -q -O  /tmp/pixel.gif "$endpoint"

Set it as a cron task and pronto! Now you should get reports that list the distance as event value and direction as event label. Reports (regular or custom) can also show you the average distance (value) your dog strays away from home in any given direction.

Step 5: Profit!

Sounds pretty simple, right? Then go get it done and do send pics of your pimped out analytics doggie!

I can already hear you say:

Hey but can’t you just shove a 3G/4G-enabled smartphone in the doggie’s pouch and have the web browser on the phone refresh a page with Google Analytics tagging until the battery dies out and still get stats?

True. But:

  1. Location stats are not that great with geoloc, even with Google Analytics.
  2. Google Analytics geolocation reports do not provide this level of geoloc refinement down to the meter, only GPS does.
  3. Google Analytics doesn’t know where your house is. Yet. 

In closing

I hope you’ll have as much fun trying this as I did with the mock online store with webcams project. You will see that is is fun to work with Raspberry Pis!

Like I said, post your pictures with your dog and screenshots on the Google+ Google Analytics Community!

Comments? Constructive criticism? Do drop me a line using the box below!

Tracking your dog with GPS and Google Universal Analytics was last modified: September 18th, 2013 by Julien Coquet

Julien Coquet

Expert de la mesure d’audience sur Internet depuis plus de 15 ans, Julien Coquet est consultant senior digital analytics et responsable produit et évangélisation pour Hub’Scan, une solution d’assurance qualité du marquage analytics.

A propos de Julien Coquet

Ce message est également disponible en : French

Loading Facebook Comments ...
Loading Disqus Comments ...

2 thoughts on “Tracking your dog with GPS and Google Universal Analytics

  1. Damion

    Julien, thanks so much for this! Insightful as always, and brought a smile to my dial 🙂

    Hopefully with a bundle of motion and bark sensors, every activity can be tracked. I wonder if a bark event could trigger a head-mounted camera to take a photo of whatever he’s barking at?

    1. Julien Coquet Post author

      Wouldn’t you like to know? 😉

      Unfortunately, as of now, the Raspberry Pi only has 2 USB ports so you can only plug in so many sensors.

Comments are closed.

No Trackbacks.