Call Tracking helps you measure the effectiveness of different marketing campaigns. By assigning a unique phone number to different advertisements, you can track which ones have the best call rates and get some data about the callers themselves.
Companies like Trulia and Datalot use Twilio to power their call tracking. Learn how do it yourself in this tutorial.
Use Twilio to track the effectiveness of your marketing campaigns. Let's get started!Start Tutorial
This Laravel web application shows how you can use Twilio to track the effectiveness of different marketing channels.
This application has three main features:
In this tutorial, we'll point out the key bits of code that make this application work. Check out the project README on GitHub to see how to run the code yourself.
Let's get started! Click the right arrow above to advance to the next code snippet.
Call tracking requires us to search for and buy phone numbers on demand, associating a specific phone number with a lead source. We make a server-side request (possibly with a filter area code) asking Twilio for available phone numbers.
When the user searches for a phone number to use for call tracking, we display a list of phone numbers that are available for purchase through the Twilio API. For each number, we create a form that, when submitted, will purchase that number through the Twilio API.
Once the user has selected a phone number to purchase, we complete the transaction using the Twilio API. When we buy the number, we specify that it should look up caller ID info on every call, and that it should use a TwiML Application we created to handle incoming calls.
When a phone number is purchased, we associate it with a
which the user can edit after a redirect.
Once we have bought a number, we display a form so the user can add a forwarding number and a description for this number. From now on, any call to this number will be attributed to this source. All phone numbers should be in E.164 format.
This is the model that contains the information provided in the
form from the previous step. The
LeadSource model associates a
Twilio number to a named lead source (like "Wall Street Journal
Ad" or "Dancing guy with sign"). It also tracks a phone number
to which we'd like all the calls redirected, like your sales or
support help line. It also provides a convenience method to
find leads associated with this lead source.
Lead represents a phone call generated by a
LeadSource. Each time somebody calls a phone number associated
LeadSource, we'll use the
Lead model to record some
of the data Twilio gives
Whenever a customer calls one of our Twilio numbers, Twilio will
send a POST request to the URL associated with this view
function (should be
We use the incoming call data to create a new
Lead for a
LeadSource, then return
TwiML that connects our
caller with the
forwarding_number of our
One useful statistic we can get from our data is how many calls
LeadSource has received. We might also want to know the
cities the leads are coming from. For this we define two Eloquent queries
that return these bits of data.
That's it! Our Laravel application is now ready to purchase new phone numbers, forward incoming calls, and record some statistics for our business.
If you're a PHP developer working with Twilio, you might also enjoy these tutorials:
Put a button on your web page that connects visitors to live support or sales people via telephone.
Send your customers automatic reminders ahead of appoiments using Twilio SMS.
Thanks for checking out this tutorial! If you have any feedback to share with us, we'd love to hear it. Tweet @twilio to let us know what you think.