Using Keen.io for your 2017 goals

Gustavo Machado
2 min readJan 11, 2017

--

2017 just started, and it’s time to renew your “annual goals”. Mine for example always include things around the lines of:

  • Read x number of books.
  • Run x number of miles (kms actually) per week/month/year.
  • Write x number of posts.
  • [ big etc here ]…

For tracking my goals, I’ve been very comfortably using a Google spreadsheet and it’s been working wonders. But this year, I’ll try something different. I decided to give some analytics platform a chance. The thing is that analytics platforms have been improving and making themselves so flexible, that I believe that it actually makes sense to use them more and more for personal data (hours of sleep, weight, etc, etc…).

I happen to stumble across keen.io again, and was very pleased with the amount of things you can do with it, and how simple it is to set it up. So I decided to give it a try. I did an awfully simple script in node.js and installed it as a command line so I can pull my terminal and quickly track things in keen. The result looks like this:

code/metrics » keen weight 96.5
Recording "weight" with value 96.5
Success
code/metrics »

If you wonder how I did it, it’s extremely simple. Here’s the script:

#!/usr/bin/env nodevar KeenTracking = require('keen-tracking');var client = new KeenTracking({
projectId: '5...2', // use your projectId here
writeKey: '2...........7' // user your writeKey here
});
var [ type, value ] = process.argv.slice(2);
var numValue = Number(value);
if (value == numValue) { //comparing number to string on purpose
value = numValue;
}
console.log(`Recording "${type}" with value ${value}`);// Record an event
client.recordEvent(type, {
value
}, function (err) {
if (err) {
console.log('An error occurred trying to record the event', err);
} else {
console.log('Success');
}
process.exit();
});

I installed the keen-tracking module with the following command:

yarn add keen-tracking

I configured the package.json so that it can be treated like a cli app:

{
"name": "keen",
"bin": "./index.js",
"dependencies": {
"keen-tracking": "^1.1.3"
}
}

Installed it globally with npm link.

Now all you have to do is play around with keen.io saved queries and dashboard so can see all your data nicely!

--

--