Advanced embed options

Calendly's embed options have customizable settings to help them fit seamlessly onto your website. Want to make even more modifications? We've compiled a list of features for developers to design their ideal booking flow using our embed code.

IN THIS ARTICLE:

 

Using the developer embed code

By making a JavaScript API call, you can create an inline embed on demand. This will allow you to delay the appearance of the embed until specific actions are completed, or until information is collected to be used for pre-filling the booking form.

Create a div on your site with a specific ID. Include the Calendly Javascript file somewhere on your site as well:

<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script> 

Then use this API call, making sure to replace the sample text with your div ID:

Calendly.initInlineWidget({
url: 'https://calendly.com/YOURLINK',
parentElement: document.getElementById('SAMPLEdivID'),
prefill: {},
utm: {}
});

Load the inline embed automatically while still pre-filling questions, or while setting UTM parameters, use the following code:

<!-- Calendly inline widget begin -->
<div class="calendly-inline-widget" style="min-width:320px;height:580px;" data-auto-load="false">
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
<script>
Calendly.initInlineWidget({
url: 'https://calendly.com/YOURLINK'
});
</script>
</div>
<!-- Calendly inline widget end -->

 

Hiding event details

Remove any information that is duplicated by the content of your web page by hiding the event details, such as your Calendly account picture, event location and event description. Add one of the following URL parameters to the code, depending on the type of scheduling link you are embedding:

A profile page or team page link:

?hide_landing_page_details=1

An event type-specific link:

?hide_event_type_details=1

 

Notifying the parent window

The embedded scheduling page notifies the parent window of important events during the booking flow. As a developer, you can subscribe to these notifications to fire analytics events or change the state of your app.

We use window.postMessage() to post events to the parent window. The event payload is a JavaScript object of the following format where XXX is the name of the booking flow event:

{event: 'calendly.XXX' }

Here are the events Calendly fires when an invitee follows the booking flow:

Event name
Event description
  calendly.profile_page_viewed   Profile page was viewed
  calendly.event_type_viewed   Event type page was viewed
  calendly.date_and_time_selected   Invitee selected date and time
  calendly.event_scheduled   Invitee successfully booked a meeting


This example code listens to these events and logs them to the console:

function isCalendlyEvent(e) {
  return e.data.event &&
         e.data.event.indexOf('calendly') === 0;
};
 
window.addEventListener(
  'message',
  function(e) {
    if (isCalendlyEvent(e)) {
      console.log(e.data);
    }
  }
);

 

Pre-Fill questions 

If you've already gathered information from visitors to your webpage, you can have it pre-populated in the booking form by modifying Javascript calls in the embed code. Prefill parameters are set in the following structure:

prefill: {
    name:
    email:
    customAnswers:
}

If your event type takes separate first name and last name fields you can use firstName and lastName instead of name.

You can also set custom answers to invitee questions you've added to your event type. Each custom answer will be numbered in order as a1, a2, a3, and up to a10.

prefill: {
    customAnswers: {
        a1:
        a2:
        a3:
    }  
}

This example code will pre-populate John Doe's contact information and his answers to the invitee questions this event type is asking:
<script>
    Calendly.initInlineWidget({
        url: 'https://calendly.com/YOUR_LINK/30min',
        prefill: {
            name: "John Doe",
            email: "john@doe2.com",
            customAnswers: {
                a1: "Yes",
                a2: "At the Starbucks on 3rd and 16th"
            }
        }         
   });
</script>


Set UTM parameters

Add UTM parameters directly by modifying Javascript calls. These UTMs will be tracked throughout the booking flow. The parameters manually set will overwrite those set in the parent window.

<script>
    Calendly.initInlineWidget({
        url: 'https://calendly.com/YOUR_LINK/30min',
        utm: {
            utmCampaign: "Spring Sale 2019",
            utmSource: "Facebook",
            utmMedium: "Ad",
            utmContent: "Shoe and Shirts",
            utmTerm: "Spring"
        }         
   });
</script>
Was this article helpful?
80 out of 163 found this helpful