How to Connect Your Own Google Sheets to This Timer
Want to automatically log your focus sessions to your own Google Sheets? Follow these simple steps:
Step 1: Create a Google Sheet
- Go to Google Sheets and create a new spreadsheet
- Name it whatever you like (e.g., "Focus Timer Log" or "Productivity Tracker")
Step 2: Add the Apps Script
- In your Google Sheet, click Extensions → Apps Script
- Delete any existing code and paste this:
javascript
function doPost(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
// Add headers if this is the first row
if (sheet.getLastRow() === 0) {
sheet.appendRow(['Date', 'Time', 'Work Description', 'Duration', 'Timestamp']);
}
sheet.appendRow([data.date, data.time, data.work, data.duration, data.timestamp]);
return ContentService.createTextOutput(JSON.stringify({result: 'success'}))
.setMimeType(ContentService.MimeType.JSON);
}- Click Save (the disk icon)
Step 3: Deploy as Web App
- Click Deploy → New deployment
- Click the gear icon ⚙️ next to "Select type" and choose Web app
- Set these options:
- Execute as: Me
- Who has access: Only myself (or "Anyone" if using on multiple devices where you're not logged in)
- Click Deploy
- Copy the Web app URL that appears
Step 4: Update the Timer Code
- Find this line in the timer code:
javascript
const GOOGLE_SHEETS_WEBHOOK = 'PASTE_YOUR_URL_HERE';- Replace
'PASTE_YOUR_URL_HERE'with your Web app URL
That's it! Your focus sessions will now automatically save to your personal Google Sheet with date, time, work description, and session duration.
Troubleshooting
- Not saving? Make sure you copied the entire webhook URL
- Permission denied? Check that you set "Execute as: Me" in the deployment settings
- Want to use on multiple devices? Set "Who has access" to "Anyone" (your URL is still private)