Stephan Schultz

@Steppschuh

Smarter Time Tracking

Automated tracking using IFTTT

There are quite a few reasons for why you should be tracking the time you’ve spent on your projects, just read through one of the many websites that sell time tracking tools. If you are tech savvy, you might actually prefer having access to an easy to use and free API that allows you to do just that.

Existing Tracking Solutions

There’s a sufficient amount of tracking tools available, peak at this list to get an idea. There’s absolutely no reason to create another Android, BlackBerry, iOS or Web App with a beautiful UI and great UX.

However, there are quite a few people who don’t want any UI. People who refuse to interact with anything that’s not a computer terminal. Or, more generic, people who would forget to press a fancy button to start tracking their time at work anyway.

Low-Level Tracking

The open-source Tracking API provides easy to use endpoints for tracking whatever you want using web requests. Be it your office hours, your workouts or how many donuts you ate. You can check out this Postman Collection to fiddle with the available endpoints.

Postman Collection with available API endpoints

The API is free to use, requires no authentication and is hosted on the Google App Engine. You can spin up your own App Engine instance, or use the public one at placetracking.appspot.com.

API Concept

The Tracking API handles 3 different types:

  • Users, representing the one who is using the API (e.g. you)
  • Topics, representing whatever you want to track (e.g. a project)
  • Actions, representing tracking events (e.g. starting to work)

So, let’s set up a demo:

Adding a User

To keep it simple, the API doesn’t require any form of authentication. You can create a user simply by calling the following URL:

https://placetracking.appspot.com/api/users/add/?name=John%20Doe

This will create a user named “John Doe”. You can expect a response similar to this:

{
"statusCode": 200,
"statusMessage": "OK",
"content": [
{
"id": 5736296311947264,
"name": "John Doe"
}
]
}

Adding a Topic

Just like the user, you can create a topic by calling:

https://placetracking.appspot.com/api/topics/add/?name=Click%20Count%20Demo

Which will result in a new topic called “Click Count Demo”:

{
"statusCode": 200,
"statusMessage": "OK",
"content": [
{
"id": 5666601139437568,
"name": "Click Count Demo"
}
]
}

Adding Actions

Now that you’ve set up a demo user and topic, you can add actions. Notice that this time we not only specify a name parameter, but also the userId and topicId from the responses above:

https://placetracking.appspot.com/api/actions/add/?name=Click&userId=5736296311947264&topicId=5666601139437568

Each time you call this URL, a new action will be added to the “Click Count Demo” from “John Doe”:

{
"statusCode": 200,
"statusMessage": "OK",
"content": [
{
"id": 5643172898144256,
"userId": 5736296311947264,
"topicId": 5666601139437568,
"name": "Click",
"timestamp": 1485002118855
}
]
}

Interactive Demo

Open the Result tab in the JSfiddle below and click on the black button. You’ll see a new “Click ”event at the very left of the chart.

Click Count Demo

Of course firing a GET request to an API every time you want to track stuff isn’t something you want to do manually. You’d be better off using the awesome triggers that IFTTT provides.

If This Then That

IFTTT is a free service for Android, iOS and the web that lets you create so called Applets. The Applets have a Trigger (e.g. you connected to a WiFi network) and an Action (e.g. turn your phone silent). Triggers and Actions can be connected from many popular services (e.g. social networks, cloud storage providers, smart home devices, …).

Tracking Applet Triggers

What triggers you select is up to you and depends on your use case. Some examples are:

If you enter / exit the location of your office, track start / stop.
If you connect / disconnect the office WiFi, track start / stop.
If you press a button, track event.

Tracking Applet Actions

To actually track anything, you need to fire a web request to the tracking API. This can easily be done using Maker.

IFTTT Applet, Trigger and Action

Here are two Applets you can copy if you own an Android device:

If you’re having any questions, feel free to get in touch!

More by Stephan Schultz

Topics of interest

More Related Stories