Answers.Body: <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T19:18:51.903Z
Answers.Text: 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.
Answers.UserDisplayName: bgm
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-06T07:36:26.733Z
Answers.Text: 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 ;)
Answers.UserDisplayName: Xavier
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T16:48:59.927Z
Answers.LastActivityDate: 2015-05-04T16:48:59.927Z
Answers.UserDisplayName: Xavier
Answers.Body: <p>Better late than never, I suppose! I wrote an extension that attaches ics files to event confirmations.</p>
  <p><a href="https://civicrm.org/extensions/event-ics" rel="nofollow noreferrer">https://civicrm.org/extensions/event-ics</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-07T19:44:35.147Z
Answers.Text: 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.
Answers.UserDisplayName: Joe McLaughlin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-06T20:57:40.253Z
Answers.LastActivityDate: 2021-12-03T14:38:58.557Z
Answers.LastEditDate: 2021-12-03T14:38:58.557Z
Answers.UserDisplayName: bgm
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>For web pages, this library seems like a pretty good solution:<br>
  <a href="https://github.com/carlsednaoui/add-to-calendar-buttons">https://github.com/carlsednaoui/add-to-calendar-buttons</a></p>
  
  <p>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:</p>
  
  <pre><code>&lt;a class="icon-google" target="_blank" 
    href="https://www.google.com/calendar/render?action=TEMPLATE&amp;text={event.title}&amp;dates={event.start_time}/{event.end_time}&amp;details={event.description}&amp;location={event.location}&amp;sprop=&amp;sprop=name:"
   &gt;Add to Google Calendar&lt;/a&gt;
  </code></pre>
  
  <p>NB: I did not test all of the above event variable names. The above probably does not work as-is.</p>
  
  <p>I was wondering: has anyone else already implemented this? any suggestions? should I worry about timezones?</p>
  
Tags: <civievent>
Title: Easy "add to Google Calendar" link in Event confirmation emails
ThreadText: # Easy "add to Google Calendar" link in Event confirmation emails
  
  (Asked by: username_0 on 2015-05-04)
  
  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:
  Add to Google Calendar
  
  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?
  
  **Tags:** civievent
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-05-06. Score: 8 | Accepted answer
  
  Better late than never, I suppose! I wrote an extension that attaches ics files to event confirmations.
  
  <https://civicrm.org/extensions/event-ics>
  
  > **Comments:**
  > **username_2**: Thanks @username_0 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.  
  
  ---
  
  ### Answer by username_1 on 2015-05-04. Score: 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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: 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 ;)  
  
  ---
  
  