Location based time tracking with iPhone & Clockify

Location Based Time Tracking

Intro

Hey folks, hope you are all well and behaving! 😉

As many of you probably do, I keep track of my work time with a time tracking solution. Not only for business purposes but I also track private projects there and use the solution quite extensively. Currently I use Clockify, which is great and easy to learn and configure.

Since I do regularly travel to some of my clients, I wondered if I could automate my time tracking. No wonder often times I forget to clock in or clock-out and then will manually need to remember the time of arrival etc.

Of course this is all done on my mobile so the I tried my luck with the built in automation tool from apple called „Shortcuts“. There you wil find a tab called „Automation“ which is able to do something for example based on your location. Unfortunately there is no built in plugin for Clockify which meant we are going to use some APIs 😉

Here is how my first working prototype looks like; still lot of room for refactoring but does it‘s job. It basically contains only 3 simple steps:

  1. Trigger > Location Based
  2. Convert Date to UTC Date
  3. Call Clockify API with the required information, which is
    • API-Key
    • Start Date (the beforehand configured UTC Date)
    • projectId > The Clockify-Project you want the time entry be made
    • description > Any description for the entry

And this is how it looks on the mobile

Obviously I deleted sensitive data and replaced it with a yellow rectangle 😉

Automation Overview

The automation itself

Configuring the Trigger

The Actions

This is where the fun beginns 😉

First of all you will need a UTC date (in my use case > The Current Date&Time) to pass this as a parameter to Clockify. There are lot better methods to do this than just “adding 2 hours”, which I did for my prototype in step one – But this will have to do it for now.

Convert Date

Make sure to convert the date to the followig format shown in the picture – Especially relevant is the trailing “Z”

Finally configure the Clockify API Call

The clockify API is very well documented here:

Clockify API Documentation

We’re going to use the operation “Time-Entries” in order to create a new time entry, as documented here:

Clockify API Documentation – Time Entries

Parameter you will need to pass for this POST Service:

  1. Complete URL > The first yellow rectangle contains your workspace ID which needs to be passed as part of the calling URL
  2. API Key > Go to your Clockify Profile and generate this Key once
  3. start > Obviously the calculated and formatted Date & Time
  4. projectId > The project ID from Clockify where the time entry should be created
  5. description > Optional, if you want to add a text like “Work” or whatever to your time-Entry

DONE

So after creating, testing and publishing this your iPhone will now notify you, when you enter the preset location.

You will then be able to confirm with a single tab on your interface, if you want to run this action and thus create a time-entry in Clockify. This will NOT happen completely automatically without notifying you. I guess the reason is to prevent someone else tracking your location based movements (there are other triggers in “automations” which DO work automatically, but not the location based one).

Setting this autmation up was very easy; I probably used most time for the simple task of getting the date & time in the correct format 😉

As always – Happy for feedback, comments etc.

Probably next one to quickly check is the obvious follwing use case “Leaving Work”.

Leave a Reply

Your email address will not be published. Required fields are marked *