9

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?

2 Answers 2

8

Better late than never, I suppose! I wrote an extension that attaches ics files to event confirmations.

https://civicrm.org/extensions/event-ics

1
  • Thanks @bgm and this seems like a great blog post topic, or the start of one, about integrating with other proprietary stuff like Gmail etc using open standards. May 7, 2020 at 19:44
5

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.

2
  • 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, 2015 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, 2015 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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