Automatic Sleep Tracking

· 3 mins read
How I successfully tracked my Sleep to my Google calendar.

When I sleep in, I want to know. When I am productive, I want to know.

I started using the iOS app Sleep Cycle to track my sleep and as an alarm. After a few weeks of using the app, I looked at my calendar and I couldn’t tell when I woke up and went to sleep each night. I wanted to know when I slept-in on weekends, or got up early.

Screenshot showing how my sleep is automatically added to my Google calendar.

I researched Sleep Cycle and found they did not have an API I could use. I paid the 69 pence for premium to access their online dashboard and found I could access the underlying data. However, this was a very long winded method to retrieving data and wasn’t a sustainable method - if they changed their front-end codebase, I would need to update my script.

I had previously experimented with tools to connect different services, such as IFTTT and loved them!

I noticed that Sleep Cycle syncs its data with Apple iOS health. I wanted to access that data and insert it into my calendar. IFTTT doesn’t directly integrate with iOS Health, so I had to look around for other services that used that data and integrated with IFTTT.

I settled on the Jawbone UP app (although I have never owned a Jawbone device) and used IFTTT, Zapier & Google Calendar to connect everything.


The most difficult issue was getting the data into the correct format for Google Calendar to process. I was almost regretting my decision to not create my own program, but then I remembered Google Sheets.

I wrote a small script to parse the sleep data into the correct format for Google Calendar to process and I was away!

function checkIfNewRow() {

  if(latest_sleep_row != latest_processed_row) {

    // Process the row

    // Append to the processed sheet

  } else {
    // do nothing, as there is nothing new

Sleep Cycle - Steps

There are several steps to complete the integration process, they are as follows:

  1. Make an IFTTT account.

  2. Create new IFTTT trigger. Using this formula.

  3. Download the UP app.

  4. To test the IFTTT trigger, go into the UP app and Track Sleep for over 2 hours, to force the IFTTT trigger.

  5. Edit the IFTTT Google Sheets Spreadsheet to have the sheets that I have in mine here. Note include 1 value to each sheet row.

  6. Create a new Google Sheet script for the IFTTT spreadsheet and add this script in it.

  7. Now at this point. Your sleep should be automatically tracked and new items post processed and appended to Sheet2. Now to add them to your calendar…

  8. Create a Zapier account (I have a whole new account, just for sleep, as this will run everyday). Use this recipe to append the sleep to your calendar in the correct format.

  9. Test everything works by force adding sleep to UP > 2 hours.

  10. You (hopefully) should see it appear in your Google calendar after the IFTTT trigger happens and Zapier trigger happens (30m max). You can force IFTTT and Zapier triggers to happen by going to the triggers and pressing run.

Google Sheets Script found here.

Google Sheets SpreadSheet found here.

Fitbit - Steps

A few months later, I managed to get my hands on a Fitbit Flex and was so happy to find it was MUCH simpler to track my sleep! I simply used this IFTTT trigger and it started logging whenever I slept! However, using Sleep Cycle was an interesting process where I utilised multiple services to achieve a goal. So I’m glad I did it!

return home