EDIT: As good as our hacked solution was, Calendly has actually released their own Google Analytics integration. You can read about it here.

If you came here looking for a solution, thanks for visiting! Have a look at our awesome marketing automation platform while you’re at it. 🙂

We are big fans of Calendly. It’s critical to our inbound lead generation as every prospect that schedules a demonstration of our marketing automation platform does so via Calendly.

That’s why it kills us that Calendly operates in a way that does not allow us to track conversions (scheduled demonstrations in our case) in Google AdWords or our own marketing automation tool.


But hey, we’re problem solvers with the technical chops to hack pretty much anything, so we took care of it and now have proper marketing attribution and conversion rates for Calendly leads in Google AdWords, Google Analytics, and of course in Net-Results. Here’s how we did it.

The Problem

Both Google Analytics and AdWords rely on “page tagging” javascripts to inform them when conversions take place. It should work like this…

  • Prospect clicks ad or other link leading them to your landing page (which has Google Analytics code on it)
  • Prospect schedules a meeting via Calendly (embedded on your landing page using an iframe)
  • Now Calendly should redirect the prospect to a URL of your choosing – a “thank you” page that indicates to Google Analytics that a conversion has just taken place. But Calendly does not offer the ability to redirect the prospect to a thank you page when they’re done scheduling via Calendly. This means Google cannot “see” that the visitor converted. No data for you digital marketers. Ugh.

The Solution (Conceptually)

The solution is to “tell” Google when a conversion has taken place. This is normally done by redirecting the prospect to a “thank you” page that also has Google Analytics code on it.

In the absence of a thank you page we have to take several steps to “tell” Google (or Net-Results or any other marketing automation platform) about the conversion ourselves.

Requirements

Unfortunately, this solution is a bit technical (it has to be, sorry). That said, a mid-level web developer should be able to handle these steps without trouble.

  • You’ll need to add some javascript on your landing page where you load the Calendly iframe
  • The creation of a page on your website that will communicate with Google Adwords/Analytics
  • Adding some code (in PHP or another web programming language) to “tell” Google that a Calendly conversion has taken place

Our website is built and managed in WordPress so we’ve used PHP to get this done. Your web developer should be able to hack this solution using Microsoft’s .Net, Java, or whatever’s in use at your company.

Getting It Done

Step 1 

When we load the Calendly iframe on our landing page, we need to pass Google’s client id (which is specific to each visitor) to Calendly. The javascript below will retrieve the Google Analytics client id and load the Calendly iframe with the client id stored in the “utm_term” variable (use a different variable if you like).

<script type="text/javascript">
    function getGACid(cb) {
        var cid = setInterval(function() {
            if (window.ga !== undefined) {
                ga('create', {
                    trackingId: 'YOUR-GA-UA-ID-HERE',
                    cookieDomain: 'auto'
                });
                ga(function(tracker) {
                    clearInterval(cid);
                    cb(tracker.get('clientId'));
                });
            }
        }, 30);
    }
    getGACid(function(cid) {
        var strHTML1 = "<div class='' data-url='https://calendly.com/YOUR-CALENDLY-URL/?utm_term=" + cid + "' style='min-width:320px;height:600px;'></div>";
        var strHTML2 = "<script type='text/javascript' src='https://calendly.com/assets/external/widget.js'></script>";
        jQuery("#calendlyContainer").append(strHTML1, strHTML2);
    });
</script>

Step 2

Create a page on your website that will receive information from Calendly for every conversion. We’ll add code to this page in step 4 below.

For now, just create an empty page called “calendly-webhook-receiver.php” or similar.

Step 3

Have Calendly send a “webhook” to the web page you created in step 2. This webhook is a way for Calendly to let your website know that a conversion has taken place. It contains information about who, scheduled what event, when, on whose calendar.If you named your page the way we’ve recommended in step 2 above, you can have Calendly send the webhook to http://www.yoursite.com/calendly-webhook-receiver.php.

If you’ve already completed step 1 above, the webhook will also contain the Google Analytics client id that can tie this conversion back to the landing page visit.

Step 4

Add code to your new web page that “listens” for webhooks from Calendly and “tells” Google that a conversion has taken place.We’re lazy so we were happy to find that some smart people have created a PHP library for sending data to Google Analytics using the “Google Analytics Measurement Protocol”. It’s free to install and use, so go get it and install it. We’ll wait.

If the Google “client id” is present in the webhook from Calendly (and it should be based on step 1 above), we “tell” Google Analytics that the website visitor went to a “thank you” page that does not actually exist. This is the key to making this entire technique work…

You’ll use the fact that the prospect “visited” this web page to track the conversion in GA/AdWords.We use different page names depending on what type of event was scheduled via Calendly such as “calendly_scheduled_demo.html” or “calendly_scheduled_training.html”.Here’s the PHP code that grabs data from Calendly’s webhook and uses the fancy library we linked to above to send our fake page view to Google Analytics…

<?php
//grab the data that Calendly sent in the webhook and store it in a variable called $objCalendlySubmission...
$objCalendlySubmission json_decode(file_get_contents('php://input'));

//We've passed the Google client_id in Calendly's placeholder for utm_term. Feel free to pass it differently, this is just an example
if(property_exists($objCalendlySubmission->payload->tracking'utm_term') && !empty($objCalendlySubmission->payload->tracking->utm_term)) {
    
$strPageViewed 'calendly_conversion.html'// We use different page names depending on what type of event was scheduled via Calendly
    
sendGoogleAnalyticsPageView($objCalendlySubmission->payload->tracking->utm_term$strPageViewed);
}

function sendGoogleAnalyticsPageView($strGAClientId$strURL) {
    require_once 
'/path_to_composer/composer/vendor/autoload.php'//loads the PHP library for the "Google Analytics Measurement Protocol”
    
$analytics = new TheIconicTrackingGoogleAnalyticsAnalytics(true); //you may have to adjust this path based on your setup

    $analytics
        
->setProtocolVersion('1')
        ->
setTrackingId('YOUR-GA-UA-ID-GOES-HERE')
        ->
setClientId($strGAClientId)
        ->
setDocumentLocationUrl($strURL);

    $analytics->sendPageview(); //here's where all the effort pays off - this part is simple :)
}
?>

  1. Next, we’ll have to set up Google Analytics to create a goal around tracking these pages you created in step 2. In Analytics, go to the “Admin” tab on the bottom left of the page. From here, you’ll click “Goals” under the “All Web Site Data” view in the rightmost column.

  2. Select “+New Goal”, and then select “Custom” in Goal setup. Name your goal, and then select “Destination” under Goal Type. Type in the URL for the page you created in step 2. Save!

  3. Now, we need to tell our AdWords account to track the goal(s) we’ve set up in Analytics. In order for this to work, we need to ensure the following:
         a. Your Analytics and AdWords accounts are linked.
         b. You’ve enabled auto-tagging in your AdWords account.
  4. Once you’ve taken care of linking the accounts, in AdWords, click on the “Tools” tab, and select “Conversions.”

Boom! You’re all done.
With this process, you’ll be able to track appointments scheduled via Calendly in AdWords.
Happy marketing,
Michael

Subscribe to the Blog

Get the latest in digital marketing, marketing automation, and Net-Results updates.

Michael Ward

I'm founder & CEO @NetResults, the 1st choice of people buying marketing automation for the 2nd time.