9 min read

How to Sync Multiple Google Calendars with Apps Script [Browser-Only Setup]

Google Apps Script Calendar Automation Beginner-Friendly
khides/calender-sync-gas

Sync multiple Google Calendars with Google Apps Script

View on GitHub →

Introduction

“Work account, personal account, freelance account… My calendars are scattered everywhere and I can’t keep track of my schedule.”

If you use multiple Google accounts, you’ve probably experienced this frustration. While Google Calendar lets you “view” calendars from other accounts, there’s no built-in feature to consolidate them into a single unified calendar.

Google Calendar Sync is a Google Apps Script solution that solves this problem.

Account B's Calendar ──┐
Account C's Calendar ──┼──▶ Account A's Main Calendar
Account D's Calendar ──┘

This guide walks you through a browser-only setup. No command line or Node.js required.

Have a development environment ready? Check out the Clasp Version Guide for easier deployment.


Who This Guide Is For

  • Users who want to set up without npm or command-line tools
  • Those who prefer a browser-only workflow
  • First-time Google Apps Script users

Features Overview

Automatic Sync

Runs every 15 minutes on a schedule, plus immediately when calendar events change. Once set up, it runs automatically without intervention.

Incremental Sync (Sync Token)

Uses Google Calendar’s Sync Token to fetch only changed events. No need to retrieve all events every time, significantly reducing API quota usage.

Privacy Modes

Control how much information gets synced with three levels:

ModeSynced InformationUse Case
busyTime slots only (shows “Busy”)Work calendar to personal account
title-onlyTitle + timeTeam calendar to manager
fullAll informationBetween your own accounts

Color Coding

Set different colors for each source calendar so you can tell at a glance which account an event came from.


Setup Instructions

Step 1: Share Your Calendars

For each source account (B, C, D…), do the following:

  1. Log in to Google Calendar
  2. Hover over the calendar name in the left sidebar, click Settings and sharing
  3. In “Share with specific people or groups,” click + Add people and groups
  4. Enter Account A’s email address
  5. Set permission to “See all event details”
  6. Click Send

Step 2: Create a GAS Project

Using Account A:

  1. Go to Google Apps Script
  2. Click New project
  3. Rename the project to “Calendar Sync”

Step 3: Enable Advanced Calendar API

  1. Click the + next to Services in the left sidebar
  2. Select Google Calendar API
  3. Click Add

Step 4: Create the Files

Create each file and copy the corresponding code from the GitHub repository:

File NameDescription
appsscript.jsonProject manifest
Config.gsConfiguration
Code.gsMain entry point
SyncEngine.gsSync engine
EventMapper.gsEvent transformation
StorageManager.gsState management
Logger.gsLogging utility
Triggers.gsTrigger management
Utils.gsHelper functions

How to create files:

  1. In the Files section on the left, click +Script
  2. Enter the file name (.gs is added automatically)
  3. Copy and paste the contents from the GitHub repository

To edit appsscript.json:

  1. Click Project Settings (gear icon)
  2. Check Show “appsscript.json” manifest file in editor
  3. appsscript.json will appear in the left sidebar - click to edit

Step 5: Edit Configuration

Open Config.gs and change calendarId to actual email addresses:

sourceCalendars: [
  {
    calendarId: 'your-actual-account@gmail.com',  // ← Change to actual email
    label: 'Account B',
    privacyMode: 'busy',
    enabled: true,
    colorId: '1'
  }
  // Add more entries for additional accounts
]

For multiple accounts:

sourceCalendars: [
  {
    calendarId: 'account-b@gmail.com',
    label: 'Account B',
    privacyMode: 'busy',
    enabled: true,
    colorId: '1'
  },
  {  // ← Don't forget the comma
    calendarId: 'account-c@gmail.com',
    label: 'Account C',
    privacyMode: 'title-only',
    enabled: true,
    colorId: '2'
  }
]

Step 6: Validate and Grant Permissions

  1. Select validateSetup from the Select function dropdown
  2. Click the Run button
  3. When prompted for permissions:
    • Click Review Permissions
    • Select your Google account
    • Click AdvancedGo to [Project Name] (unsafe)
    • Click Allow
  4. Check the execution log to verify all calendars show “Accessible”

Step 7: Set Up Triggers

  1. Select setupTriggers from the Select function dropdown
  2. Click Run
  3. Verify triggers were created in the execution log

Step 8: Initial Sync

  1. Select manualSync from the Select function dropdown
  2. Click Run
  3. Verify events appear in Account A’s calendar

Configuration Options

Privacy Modes

ModeDisplay
busyShows “[Label] Busy” only
title-onlyTitle and time only (no description/location)
fullCopies all information

Color IDs

IDColor
1Lavender
2Sage
3Grape
4Flamingo
5Banana
6Tangerine
7Peacock
8Graphite
9Blueberry
10Basil
11Tomato

Operations & Maintenance

Available Functions

FunctionDescription
manualSync()Run sync manually
validateSetup()Validate settings and access
setupTriggers()Set up automatic triggers
clearTriggers()Remove all triggers
showStatus()Show sync status
forceFullSync()Run full sync for all calendars
resetAllData()Reset all sync data
removeAllSyncedEvents()Delete all synced events

Troubleshooting

Cannot Access Calendar

  1. Verify the calendar is properly shared from the source account
  2. Check if Account A has subscribed to the calendar (Calendar > Other calendars > Subscribe)
  3. Verify the calendar ID in Config.gs is correct

Sync Not Working

  1. Run showStatus() to check status
  2. Verify triggers are configured
  3. Check execution logs for errors

Sync Token Error

sync token invalidated, running full sync

This is normal behavior. It means Google reset the token, so the script fell back to a full sync.

Quotas and Limits

ItemLimitMitigation
Event creation/day5,000Minimized with incremental sync
Script execution time6 minHandled with pagination
Trigger time/day90 minEfficient with sync tokens

Technical Details

A brief explanation of what happens behind the scenes.

Incremental Sync with Sync Tokens

Google Calendar issues a Sync Token each time you fetch the event list. Pass this token on the next sync, and only events changed since the last fetch are returned.

This eliminates the need to fetch and compare all events every time, reducing API quota usage by over 90%. Tokens expire after a period (typically ~7 days), but the script automatically falls back to a full scan when this happens.

Event Mapping

Synced events include metadata linking them to their source events. This enables:

  • Source event updated → Destination automatically updated
  • Source event deleted → Destination automatically deleted
  • Destination event accidentally deleted → Recreated on next sync

This ensures consistent state management.

Dual Trigger Strategy

Two types of triggers work together to balance real-time responsiveness with reliability:

TriggerAdvantageDisadvantage
Calendar triggerFires immediately (<1 min)May fail due to permissions
15-minute timerReliable executionUp to 15-min delay

Usually syncs immediately, with guaranteed recovery within 15 minutes if anything fails.


Summary

Google Calendar Sync lets you consolidate calendars scattered across multiple Google accounts into one.

  1. Share calendars from source accounts
  2. Create a GAS project
  3. Copy and paste the files
  4. Configure source calendars in Config.gs
  5. Run initial sync

Once set up, sync runs automatically. If you’re struggling to manage too many calendars, give it a try.


Source Code

khides/calender-sync-gas

Sync multiple Google Calendars with Google Apps Script

View on GitHub →