_docs-v3/event-data/google-calendar.md
FullCalendar can display events from a public Google Calendar.<!--more--> Google Calendar can serve as a backend that manages and persistently stores event data (a feature that FullCalendar currently lacks).
<div class='warning'> On Nov 17th 2014, Google shut down V1 and V2 of their Calendar APIs, which FullCalendar relied upon. Please upgrade to the latest version of FullCalendar or at least replace <code>gcal.js</code> with <strong><a href='https://github.com/fullcalendar/fullcalendar/blob/v3.7.0/dist/gcal.js'>this file</a></strong> (will work down to FullCalendar v2.0.0). Also, your own Google Calendar API key is now required. </div>You must first have a Google Calendar API Key:
Make your Google Calendar public:
Obtain your Google Calendar's ID:
Next, you must have all the required js/css files. This includes the standard fullcalendar.js and fullcalendar.css, in addition to gcal.js:
<script type='text/javascript' src='fullcalendar/gcal.js'></script>
Now it's time to initialize your calendar in JavaScript. This is the most minimal example:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
googleCalendarApiKey: '<YOUR API KEY>',
events: {
googleCalendarId: '[email protected]'
}
});
});
</script>
If you want to specify some Event Source options, you can include them in the events object:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
googleCalendarApiKey: '<YOUR API KEY>',
events: {
googleCalendarId: '[email protected]',
className: 'gcal-event' // an option!
}
});
});
</script>
View a demo that displays US holidays from Google Calendar.
The Google Calendar plugin respects the timezone parameter. If it is false (the default), the timezone setting of the Google Calendar will be used, as defined in Google's UI. If it is specified, this will be ignored and the timezone will be forced.
You can specify multiple Google Calendars by using the eventSources option:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
googleCalendarApiKey: '<YOUR API KEY>',
eventSources: [
{
googleCalendarId: '[email protected]'
},
{
googleCalendarId: '[email protected]',
className: 'nice-event'
}
]
});
});
</script>
Google Calendar's API allows you to specify Extended Properties for your events. The extended properties will be available as the extendedProperties hash that is attached to each Event Object.
If you need different API keys per calendar, you can set a googleCalendarApiKey option on each individual Event Source when written in extended form.
If you need to detect errors with the Google API, there's no way to get at this with jQuery's AJAX error handler. You'll need to use the FullCalendar's googleCalendarError callback, which is available as a normal option, or a per-Event Source option.