Create an "Add to Calendar" Link

An "Add to Calendar" link will allow your PURL visitors to automatically add an event to their calendar.  The cool part is, that this event can change based off the PURL visitor's input!  Here is how you can pull this off...

1. Add a Page

The first step is to add a new page to your campaign. This will serve as the page that will download the calendar (ics) file. You can name this page something like "Download Event"

2. Submit to Thank You Page

When you created the new Download Event page, the Welcome page will be updated to submit to the that new page.  We'll want to update the Welcome page to submit to the "Thank You" page.  You can do that under the Form tab > Go To Dropdown.

3. Add Link to the Thank You page

You should create a new link on the Thank You page that goes to the Download Event page.  To do that, select the Link dropdown in the content editor. 

4. Add the Calendar Script

You will now want to add the calendar script below to the landing page (index.php) file.  This is the file stored on your server that you can access via FTP. If your using instantPurl, you can request FTP access.

Check out this video for a brief walkthrough for what this code all means.

if($_GET['page'] == 2) { 
$summary = 'Appt with ABC Corp'; //The name of the event
$location = '123 Main Street'; //The location of the event
$filename = 'event.ics'; //the name of this file for saving (e.g. my-event-name.ics) 
$day = explode('/',$visitor->customfield_XXXX); //This should be replaced with your custom field ID for the date
$time = $visitor->customfield_XXXX; //This should be replaced with your custom field ID for the time 
//Calculate the start/end time for the event
$timestamp = $day[2].'-'.$day[0].'-'.$day[1];
if(strstr($time,'AM')) {
$time = str_replace(' AM','',$time);
} else {
$time = str_replace(' PM','',$time);
$time = explode(':',$time); 
$time[0] = $time[0]+12;
$time = $time[0].':'.$time[1];}
$timestamp = $timestamp.' '.$time;
$start = $timestamp;
$end = date('Y-m-d H:i', strtotime($timestamp.' + 1 hours')); 
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $filename);
function dateToCal($timestamp) {
return date('Ymd\THi', $timestamp);}?>
PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VEVENT
UID:<?= uniqid() ?>
DTEND;TZID=America/New_York:<?= dateToCal(strtotime($end)); ?>00
SUMMARY:<?= $summary; ?> 
DTSTART;TZID=America/New_York:<?= dateToCal(strtotime($start)); ?>00
LOCATION:<?= $location; ?>