Are you truly understanding your advertising metrics? Set up call tracking on Twilio

August 01, 2019
Written by

Understanding_the_performance_of_your_advertising_is_important.png

In the US, calls from paid advertising continue to grow at a rate of ~18% year over year. In 2019, we expect to see 162 billion calls from search, social and display ads and there’s no indication that things will slow down. With so many calls originating from digital ads, it’s critical that marketers understand the performance of their advertising so they can focus their efforts on the channels and ads that are working, and re-strategize on the ones that are not.

calls from ads.png

 

It can be complex, but we make it easy

Setting up your first call tracking application for your ads can be daunting, there are lots of things to consider: 

How many phone numbers do I need if I’m running X different ads on X different platforms with X different ad campaigns?
How do I attribute call leads? From the ad platform or from the campaigns I’m running? What about the ad content?
How do I get that data? How do I store the data?
Where do I place the phone number!? On the ad or on my website?
Should I also measure user behavior as well as calls?

In these next few sections we’ll answer all of these questions, before illustrating how to setup call tracking on Twilio.

How does it work?

Firstly, it’s not going to work without a phone number. So you should buy one of those.

Most people associate call tracking with SEO, PPC and the big ad platforms. But you can place a phone number on any medium that allows you. For digital channels, it’s usually these four areas - 

  1. Ads (PPC) - Google, Facebook, LinkedIn etc.
  2. Landing/Listing Pages (SEO) - inner page URLs on your own domain.
  3. Content Marketing (Blog/PR) - content placed on external URLs, not your own domain. 
  4. Directory Listings/Citations - a webpage on any website on this list.

But really, YOU CAN PLACE NUMBERS ANYWHERE!

 

place_numbers_anywhere.png

 

Dynamic Number Insertion (DNI)

As well as placing numbers on ads, you can also dynamically insert numbers onto your webpage. You do this by manipulating the DOM and instructing your webpage to look out for specific attributes in order to insert the correct call tracking number on the page. Here is some source code for a basic implementation.

numbers.gif

When you use DNI, you might see something like this:

Normal Homepage URL

Owl-mart.png

UTM-Tracking URL

Owl-mart2.png

Notice how the number has changed, along with the URL string..

What’s a UTM-Code?

If you are measuring the performance of your Paid Advertising, you’re going to need to use UTM-Codes. 

They’re simple “codes” or “parameters” that you can attach to a custom URL in order to track your advertising. There are different types of UTM parameters, but the 3 main types are - 

  • UTM-Source: which tracks where the traffic is coming from, such as Google
  • UTM-Medium: which tracks the type of traffic, or which kind of tool you used to get it, such as paid search or it might even be “email”
  • UTM-Campaign: which tracks the actual advertising campaign that you got your traffic from.

Screen Shot 2019-07-31 at 3.57.29 PM.png

Using Web Cookies

You may not just want to measure calls to your ads, perhaps you also want to track what your users are doing in their session on your website. In order to do this, you must give them a web cookie. 

Cookies are labels that describe useful information about users that visit your webpage. These cookies should be unique and contain an ID that your platform uses to keep track so it can insert the right call tracking number.

When a unique user (or at least device) is back on the webpage, we can re-insert that call tracking phone number for that human/device in order to track the call back to their existing session (and also their web behaviour - what pages they clicked on, how long they remained on your website etc.). If your site has a lot of traffic, you can look at pooling your phone numbers. In most cases, assigning a unique phone number for every website visitor just isn’t a feasible solution.

Number Pooling

This involves recycling numbers from our number pool every time a visitor leaves and a new visitor joins. Your platform must host these numbers so you can programmatically assign new numbers when needed. 

When using Cookies or localStorage() for call tracking, you would check to see if the number previously allocated to that visitor is still available, if so, show them the same number. If not, you can show them a new one that’s available from your number pool. In both cases, you should retain user data as it pertains to their new website session, associated to their unique ID.

Call Attribution

By defining our UTM-Parameters or using web cookies to assign numbers, we now have different ways we can start attributing calls, which is the crux of what we need in order to start effectively measuring the performance of our advertising. We now have the ability to attribute calls in multiple ways:

attribution_types.png

Setup Time!

Now that we know the fundamentals, let’s get started with call tracking as it applies to your use-case using a simple, intermediate and advanced framework. 

Simple Setup

Here we’ll be setting up call tracking entirely within the Twilio console and with just 3 lines of code.

  • Step 1: Navigate to Numbers, search for a number with the area code you want, and buy the number
  • Step 2: Add that number to your advertising 
Screen Shot 2019-07-30 at 2.45.42 PM.png
  • Step 3: Create a TwiML Bin here. Add this code:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Dial>+14052465213</Dial>
</Response>
  • Step 4: Configure the phone number so that when a call comes in, it invokes your TwiML bin. To do this, simply select TwiML from the drop down menu of A call comes in 
Screen Shot 2019-07-30 at 2.52.05 PM.png

You’ve just setup call tracking! This is what’s happening when you go to make a call to your Twilio number

Intermediate Setup

Now it’s time to start using APIs. You would use these steps if you wanted to programatically purchase numbers for campaign, source or medium-level call attribution.

  • Step 1: Find a phone number (I'm filtering by my local Austin area code - 512)
client.availablePhoneNumbers('US')
      .local
      .list({areaCode: 512, limit: 20})
      .then(local => local.forEach(l => console.log(l.friendlyName)));
  • Step 2: Buy that number
client.incomingPhoneNumbers
      .create({phoneNumber: '+15121234567'})
      .then(incoming_phone_number => console.log(incoming_phone_number.sid));
  • Step 3: Configure the number to your application containing TwiML
client.incomingPhoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXX')
  .update({voiceUrl: 'https://your-local-service/update'})
  .then(incoming_phone_number => console.log(incoming_phone_number.friendlyName));
  • Step 4: Make sure the URL you have used for the number has valid TwiML and is forwarding to the correct business phone number
const VoiceResponse = client.twiml.VoiceResponse;
const response = new VoiceResponse();
response.dial('405-123-4567');
console.log(response.toString());
  • Step 5: Programmatically add numbers to your advertising campaigns and/or webpages using DNI for those campaigns
  • Step 6: Add scripts to your website/app to dynamically insert phone numbers based on attribution measurements
  • Step 7: GET call data for each call!
client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .fetch()
      .then(call => console.log(call));

Sweet! Now you’re setup in your own environment. Here’s what’s happening - 

flow_2.png

Advanced Setup

Now it’s time to provision numbers on the fly, dynamically insert them to our web-pages, create a number pool within our application and expose the call tracking metrics that we want to measure within a UI. For this setup, please see the full source code here.

To finish things off, you don’t have to do it alone. We have great partners, including Scorpion Marketing, who can set your business up for success with call tracking.