What is the Measurement Protocol?
The developer guide for the measurement protocol succinctly offers this description;
The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers. This allows developers to measure how users interact with their business from almost any environment
What does this mean in the real world?
It means those with a curious nature can hook up offline activity and send that interaction data to Google Analytics to slice & dice. It also means it opens the door to spammers and unscrupulous marketers to send referral and any other kind of interaction data to your Google Analytics account without having to interact with your connected properties.
Let’s not talk about the second use too much, that’s a different conversation. Let’s instead concentrate on how we can use the Measurement Protocol more for it’s intended use.
For me, back in October 2015 I had an epif epiph I realised I could use the Measurement Protocol if i could get my hands on an Integrated Developer Environment (IDE). All I would then need to do is build the Hit I wanted to send from that environment. Now armed with how I thought it would all work, I needed to find that product with an IDE, which is where SmartThings comes in.
What is SmartThings?
I would nick a paragraph explaining what SmartThings is from their site but it uses words and paragraphs that I cannot figure out the meaning of, salesy type stuff. Instead let me try and offer my meaning;

SmartThings is an Internet of Things connected hub with interactive devices you can control and monitor via a smart app.
The starter kit comes with;
- hub
- presence sensor
- power outlet
- motion sensor
- multi sensor
You can buy more of these separately, the starter kit costs around £200, it’s also available via some Google Shopping merchants for around £9k. Personally i went with the £200 option.
The setup is very straightforward, plug the hub into your router via the supplied Ethernet cable and start connecting your devices however you want to use them. I set up my motion sensor on the stairs, multi sensor on the front door, presence sensor on my car keys and power outlet on the lamp in my living room.
Now that I was connected, it was time to get to work trying to pickup the activity through the motion sensor on my stairs, this was where i called in the help of Simo Ahava. Simo just knows JavaScript upside down and inside out – couple this with his Google Tag Manager & Google Analytics knowledge and he is just the absolute go to guy when i get stuck. I’ve been stuck a few times. Simo helped. Simo always helps, he’s a nice guy.
SmartThings IDE

The SmartThings IDE allows you to control your locations, hubs and devices as well as access the developer tools and documentation. This was a huge leap in my quest to understanding how often my stairs were being used. Once registered for the IDE and after adding your new “location”, you can add your new “SmartApp”.

Here is the code for you to shamelessly borrow for your own use. Modify it, play around with it, connect it to different devices. Have fun with it.
There are also a tonne of inbuilt templates that you can use and adapt that have been developed by others, accessible via the “From Template” link. I especially like the “Ridiculously Automated Garage Door”, but also the “Elder Care” routine (something I also envisaged but never built).

Alexa & SmartThings
The possibilities are endless with connected devices. I’ve bought an additional 3 Power Outlets and use them interchangeably throughout the year, renaming them in the app & controlling them via the Alexa App.
Some of my common routines;
- “Alexa, Turn on the Christmas lights” (controls all inside & outside on/off)
- “Alexa, Game time” (Turns on heating, Fruit machine, Playstation etc)
While these are dependent on just Power Outlets & Amazon Alexa (SmartThings Smart Home enabled Skill) there are endless possibilities to use your connected home. And measure it.
My next step is to create another Amazon Alexa Skill, but this time, an interactive version of Link Builder where I can send the interaction data back to Google Analytics as an event. That way, I truly can understand that it is 99% people swearing at Alexa.
SmartThings + IFTTT
Just as a brief experiment I thought I would hook SmartThings up to Twitter via IFTTT for no other reason other than to see if it worked. Now every time there was motion detected on the stairs it would tweet that activity. I can think of other similar uses and again not a huge leap of faith to envisage creating an automated blog of activity.

GA Dashboard
Also I could easily imagine the use of the Multi Sensors in a retail environment to control staffing levels based on Google Analytics historical data. A connected Multi Sensor triggering an event every time a store door opens/closes. Or even rear of store deliveries. That time data would improve staffing levels at a much cheaper rate than current solutions on the market.
The caveat to that though is not everyone is Google Analytics friendly so that data and consumption would also have to be simplified, I wrote a post a few years back on A Guide to Custom Reporting Using the Google Analytics Spreadsheet Add-on, that would be the perfect solution.
So what does the motion on my stairs data look like?
Apart from the time I forgot to change the battery in the sensor (and some weird Skynet thing where it sourced its own power) it looks like this;

What does all this have to do with Search?
“It’s the year of mobile”, “It’s the year of voice search”
Sound familiar?
While there are efforts out there to understand interaction between devices using User-ID, that can surely only tell part of the story.
Why can’t we better integrate Google Analytics into our Alexa Skills and developer environments such as SmartThings or our Raspberry Pi’s.
With that better connected data we will have a better picture of how our products and services truly are being used. And improve them further.
Have a similar integration? I would love to know about it!




Really nice share and innovation. Did you feel differently about it after, or it had changed your perception?
Thanks Tristan. It kind of achieved what i wanted it to, i just wanted to see a working environment that I could later expand on. It was a bit of a learning curve wrapping my head around around the way SmartThings codes the SmartApps (Groovy – http://docs.smartthings.com/en/latest/getting-started/groovy-basics.html) as i’d never faced it before, but like most languages it follows a logic.
Even though it has been a few years i still feel excited about its possibilities and i have this morning bought another Multi Sensor to put onto my beer fridge to answer another burning question i have. (blame Kevin Ellen on twitter for that idea).
🙂 nice, keep up the good work