6

Are there recommended practices for adding a link in Event email confirmations so that users can easily add the event to their Google Calendar? By default, CiviCRM offers that users download the .ical file, which they can then add to their calendar.

I would like to offer a direct "add to google" link. While not everyone uses Google (I'm one of those who do not), a few of my users have requested this feature.

For web pages, this library seems like a pretty good solution:
https://github.com/carlsednaoui/add-to-calendar-buttons

However, we cannot embed javascript code in emails, so it needs to be simpler. It seems like we can use an URL of the following form, which can be included in message templates:

<a class="icon-google" target="_blank" 
  href="https://www.google.com/calendar/render?action=TEMPLATE&text={event.title}&dates={event.start_time}/{event.end_time}&details={event.description}&location={event.location}&sprop=&sprop=name:"
 >Add to Google Calendar</a>

NB: I did not test all of the above event variable names. The above probably does not work as-is.

I was wondering: has anyone else already implemented this? any suggestions? should I worry about timezones?

3

What about going "the extra mile" and add the event information as an attachment of the right content type? That would allow gmail to automatically add the event to the calendar and would work with other calendar events too.

Not sure how to paste the code without looking like crap here, but if you use google calendar and invite your (non gmail) email, you will see the format google generates (and understand) that is fairly standard iCalendar format for what I recall.

  • Good point. Do you think we should add it in core, or in an extension? CiviCRM already generates the ICS file anyway, it's just not included as an attachment. – bgm May 4 '15 at 19:18
  • If not more difficult, I like the idea of trying to make the core leaner, so I rather see it as an extension (one that I will add to my pack of extensions I always put ;) – Xavier May 6 '15 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.