Forget Streaks: A Smarter Way to Track Habits Without Stress

Back to posts

I’ve been looking for a way to track and motivate myself to build healthier habits, specifically around exercise, meditation, and phone use. So I started looking for a phone app that would let me see exactly how much time I was spending on each. There are plenty of habit-tracking apps out there, but they all seem to have the same shortcomings:

So I decided to make something bespoke.

I set up a MySQL database on my server where each row logs a start time, end time, and a label for the habit it’s tracking.

SQL Row example for tracking activities.

Meditation

The first habit I tackled was meditation. This one was fairly straightforward. I made a very simple meditation timer, similar to this one my friend Hugh built, but mine automatically logs the start and end times of each session into the database.

The one snag I ran into: since the timer is hosted on a web page, my MacBook would fall asleep after 10 minutes of inactivity, which stops JavaScript execution once the device locks. The fix was to run caffeinate in Terminal while the timer is active, which prevents sleep and keeps the code running. Once I figured that out, it worked great and I’ve been using it ever since. I won’t link to my version since I don’t have authentication on my server, but here’s a screenshot:

Screenshot of the meditation timer web page
Meditation timer.

Cardio

The next habit I wanted to track was cardio. My goal is 2.5 hours per week, since that’s what the WHO recommends for maximum cardiovascular benefit before diminishing returns. I already use Strava for runs, so my first thought was to pull the data from their API with a cron job. But since I don’t need most of that data and didn’t want to deal with authentication, I went with Apple Shortcuts instead.

When I open Strava, a Shortcut sends a POST request to my server to log the start time. When I close the app, it sends another request with the end time. It’s a crude setup, but it works well enough. I may switch to the API later if I need more detail.

Strava Apple Shortcuts in action

Strength Training (Bouldering)

After that, I set up strength training. Again, the WHO recommends 2.5 hours per week, and for me that’s bouldering, since it’s the only strength exercise I enjoy. Tracking it turned out to be even easier than running. Using Apple Shortcuts, my phone sends a POST request with the current time when I arrive within 500 meters of my climbing gym, and another when I leave. That session gets logged automatically. I use the same method for football: when I arrive and leave the pitch, it tracks that as cardio.

Climbing Gym Shortcuts setup

Procrastinatory Web Use

The last habit I wanted to measure was procrastinatory web use, which was trickier. I needed to track activity on both my MacBook and my iPhone.

The solution came when I discovered that iOS’s new Screen Time data can be accessed via Shortcuts (in the beta, at least). It only seems to cover Safari, but that’s enough for me. I set up a daily automation (runs at 12:30am) to pull the previous day’s web activity and send it to my server. Since Screen Time gives durations, not timestamps, I just fudge timestamps to make it work with the rest of my system. It’s not perfect, but it does the job.

Climbing Gym Shortcuts setup

Presenting the Data

Once I had everything logging properly, it was just a matter of presenting it. I built a simple dashboard where each habit has a progress bar showing how close I am to the weekly target. Bars turn green when I hit the goal and red when I don’t.

Awards (Peanuts)

I also added a small “award” system using peanuts. (I chose peanuts because they feel sufficiently minor/insignificant/meaningless).

A screenshot of the peanuts system...

A counter at the top tracks how many weeks I’ve won each award. It’s obviously extremely contrived and pointless but it does gamify it in a way that makes even small wins feel good. Anyway, you can check the finished thing out here if you like.

Just don't judge me for how badly I'm doing at sticking to my habits...