A frequent need for many community and groupware websites is an event calendar. Though there are many calendar solutions available in commercial offerings, custom built and smaller sites often find it difficult to find a solution that is both cost-effective and feature rich. This white paper examines how to use the existing Google Calendar infrastructure, by way of the published API, as the foundation for a fully featured calendar and event management system.
Background
Google Calendar was introduced by Google in 2006 as a web based, standards compliant calendar application. In addition to the client interface, Google also published the full Application Programming Interface (API) so that third party developers could interact with the underlying data stored in the Google Calendar system. The API is based on Atom RSS, an XML based publishing protocol operating over HTTP. Because it is based on XML and Atom, the API is easily used by almost any programming language available, as long as there is a generic HTTP and XML parsing library available.
In addition to the API, Google also provides an easy way to embed Google Calendars in third party websites using HTML <iframe> tags. This allows websites to use the display capabilities of the Google Calendar client on their own sites. The embedded calendars can be customized to match the look and feel of a website while retaining the classic Google branding and style.
This document assumes basic familiarity with the Google Calendar service, as well as knowledge of basic programming concepts, including XML and HTTP.
Advantages of Integration with Google Calendar
It is possible to use the Google Calendar service as both the data provider (via the API) and the display system (through the embedded <iframe>) for a calendar, or as either option individually.
Using the Google Calendar system as a basis for a Calendar/Event Management system can provide many benefits:
- Reduced Development Time: Google has implemented a robust, tested data model that can be leveraged for event storage and processing. The well document API decreases development time by providing an existing data model and framework from which to build from.
- Rich Feature Set: the Google Calendar service implements a range of useful features, from RSS syndication of calendars to Event attendee support. These features are all standards compliant, ensuring interoperability with major calendaring applications like Microsoft Outlook and Apple iCal.
- Improved Reliability: the Google services are enterprise applications that have an uptime > %99.9.
- Cost Effectiveness: the Google services are free – using the API requires nothing more than a standard Google account, but you gain an enterprise level tool for your website.
- Customization: Google provides many options for customizing the look and feel as well as the functionality available through the Google Calendar API. You can choose to use only those features that you need, and a display that matches the look-and-feel of your site.
Taken together, the benefits and features of using the Google Calendar system to power an event management/calendar system can be compelling for the small to medium sized website.
Requirements
In our experience, small to medium sized community based sites have a common set of requirements for a calendar/event management system:
- Display a publicly available calendar of events
- Display private calendar events restricted to members/registered users
- Categorize events by type and display in discrete sub-calendars
- Allow users to submit events
- Accept/Reject submitted events
- Manage events, including updating and deletion
System Design
Building a system that interacts with the Google Calendar system has three main components:
- The application server
- The display subsystem
- The event management staging subsystem
Figure 1 details the structure of the system. The application server is the underlying structure and code upon which the website is based. This may be any content management system, Ruby on Rails, etc.
The display subsystem includes all of the forms and ‘views’ that provide an interface to the user. Within the display subsystem, and the main interface to the Google Calendar data is the embedded Google Calendar. The calendar is embedded using <iframe> tags pointing to a Google hosted calendar resource. Options are passed in the <iframe> source parameter, instructing Google on how to format the returned HTML calendar. The display subsystem manages the display of the embedded calendar by dynamically updating the <iframe> and source parameters.
The event management staging subsystem handles events before they are committed to the Google Calendar service. This is essential if a requirement for the system is to approve/reject event submissions before they are displayed publicly. The staging subsystem can also provide a mechanism for storing and displaying additional information other than what Google provides in the default event data model (examples of this may be contact information, admission costs, website, etc.)
Workflow
The workflow for the system is relatively simple. First, a user views a form with fields for entering all of the event information, then submits that information to the application server. Assuming everything is validated, the event information is saved into the Event Staging System. Before the event is saved to the Google Calendar service, it is reviewed and approved by a site administrator or other designated user. Once the information is approved, the event staging system saves the event to the Google Calendar system using the Google Calendar API. At this point, the information is ‘live’ and viewable on the calendar.
Any changes to the event go through the Event Staging System rather than the Google Calendar interface – this way, all changes are tracked and approved in the staging system before being made public.
Staging System Data Model
The key to synchronizing information between the Staging system and the Google Calendar system are unique IDs. Google assigns unique IDs to all calendars and events within its system, providing the Staging system with a way to select and track data within the Google Calendar system. By saving this ID locally with the event information, a representation of the Google event is made. Any change then made to the local representation of the event can be transparently saved to the Google representation via the unique ID.
Interacting with the Google Calendar API
Assuming the Application server is built using a MVC framework, the obvious place for interacting with the Google Calendar service is through the model. The model will already contain the methods to save and update data, so it is a simple task to add the equivalent code to save the same information to the Google Calendar service.
Data Duplication vs Latency
A key thing to note about the system design described above is that data exists in two places simultaneously; in the staging database and the Google calendar service. This is a design decision that weighs the latency cost of communicating with the Google Calendar service against the technical hassle of maintaining two separate data sets for the same event.
Depending on location, a typical API request to the Google servers will take anywhere from 200 to 600 ms to complete. The most basic ’save’ POST operation to the Google calendar service requires two requests, one to authenticate and one to send the data. Combined, these calls can take anywhere from 1/2 second to 1 second to complete, a very noticeable number for the end user. And 2 requests to the Google service is the absolute minimum. Therefore, using the Google service as the sole repository of the data, while possible, brings a sacrifice in perceived usability because of the overhead cost of the API requests.
The alternative, as outlined above, is a hybrid approach. Latency is reduced by only communicating with the Google Server when necessary, i.e. when updating the displayed data on the Google servers. For all other operations, such as searching for a particular event or populating a form with event data, the local staging table can be used, providing a faster end user experience.
However, this approach requires special care to reduce potential uses where data can become out of sync. A simple set of design rules can help eliminate these situations:
- Information should flow in one direction – i.e. only one data set should be the ‘master’, and all others are updated from that set.
- If a remote save operation fails and data can not be updated to the remote service, the local operation should fail and no local data should be saved.
- If in doubt as to whether the remote copy is in sync with the master copy, do a full replace of the record from the master set.
Conclusions
Implemented correctly, integrating Google Calendars on your site can save time, lower development costs and give you cutting edge and standards compliant features, all for free. The architecture outlined here will allow you to retain the look and feel of your own site, while making use of the features provided by Google through the Calendar API.
Have questions or want to discuss a project? Feel free to contact me. Comments and thoughts are always welcome.


s, but I’ve wanted to create my own library that includes the functionality I’ve had to monkey patch into others’. So, I’ve gone ahead and created
app with Google Calendar so that the milestone information would be available to anyone who wanted to subscribe to it. I looked around and found a couple of google calendar integration libraries, but suprisingly there isn’t a fully implemented GData API that allow access to all the features of the Google Calendar API.