Your Strategic SEO outsourcing partner

Call us at: 303.905.1504

Navigation

Sections navigation

seOverflow Blog

‘Roll Your Own’ Phone Call Tracking Program – It Is Easy!

So you wanna track phone calls eh? Easy enough my friend. There are some excellent call tracking platforms out in the world including IfByPhone, Mongoose Metrics, VoiceStar and more. We’ve researched a ton of them and while they all had their upsides, each had a downside as well that was hard for either seOverflow or our clients to stomach. In order to solve most of these issues, we went and developed our own phone call tracking program based on the Twilio Web Service API for phone applications. Features that were important to us that were hard to find together in a single call tracking application were:

  • affordable for most clients
  • ability to port numbers in and out
  • integration with Google Analytics for conversion tracking
  • call recording
  • email alerts when a call was made
  • showing the ‘real’ phone number in the code to help with local search
  • easy to implement
  • ability to track only non-branded organic search traffic
  • and more!

In this post we are going to show you EXACTLY how to build your own phone call tracking platform you can put in use TODAY for you or your clients. You’ll need to at least understand a teeny bit of JavaScript, PHP, XML, HTML, and Google Analytics. You’ll also need PHP and Google Analytics installed on the website for which you intend to track phone calls. For the example, we are going to build a call tracking program that tracks phone calls as a result of a non-branded organic search from one of the big three search engines (Google, Yahoo, or Bing).

Building The ‘Back End’

Step 1: Register for a Twilio account. An account with Twilio is free! Phone numbers are only $5.00 per number per month, and calls cost only 3 cents per minute for ‘local’ calls or 5 cents per minute for toll-free calls. You can start by using numbers for free from the Twilio sandbox. You also get $30.00 worth of credit for free to get started!

Register For Twilio

Step 2: Buy three ‘local’ phone numbers in your account. You can search by area code for the phone numbers you want. When you find a number you want, Twilio will request a URL to associate with this number. A default URL will be filled in. Leave this default in place for now. You should now have a table with three numbers.

Buy A Phone Call Tracking Number

Step 3: Download our phone call tracking code sample zip file here. Once the file is downloaded, open up calls/twiml.php in your favorite editor. Once the file is open, replace XXXXXXXXXX with the phone number where you would like Twilio to forward your calls. Save the file.

Replace Phone Number

Step 4: Open calls/handler.php in your favorite editor. Replace UA-XXXXXX-1 with your Google Analytics profile ID. Also replace youremail@domain.com with the email address where you wish to get notices when a call is logged including a link to the recording of the call. Save the file.

Replace GA ID

Replace Phone Number

Step 5: Upload twiml.php, handler.php, and Galavanize.php to a directory called/calls on your website.

Step: 6: Go back to Twilio. Decide which number you are going to use for Google visitors and click on the number in the table. Edit the description of the number (currently contains the number itself) to Google. Edit the URL to be http://www.yourdomain.com/calls/twiml.php?callsource=Google (replace yourdomain with the domain you are working with). Hit Save.

Edit Phone Number

Step 7: Now it is time to test and make sure the phone numbers work, forward to your phone, send an email, hit your Google Analytics account, record the call, and finally send you an email. All that in seven steps.  All you need to do to test is call the number you assigned to Google (don’t call from the phone to which you are forwarding calls). If the destination phone rang, you had a conversation, and you received an email telling you  a call from Google just came in with a link to the recording of your call, then it worked! If not, check the Debugging link in Twilio and see if your program generated an error message. It can take a couple of hours, but a page view will also show up in your Google Analytics profile for the URL/calls/Google.

Building The Front End

Now that the back end of our call tracking application is working, we need to build the logic that controls which phone number to display. Rather than reinventing the wheel and coming up with our own code to detect the referrer and other information about the visitor, let’s use what Google Analytics already knows! The code we use to read the Google Analytics cookie is based on the code written by EpikOne and published in their blog post “Integrating Google Analytics With A CRM“.

Step 1: Open displaynumbers.js in your favorite editor. Enter your phone numbers as values for the appropriate variables. Enter them formatted how you would like them displayed on your web page. Enter your ‘real’ or default phone number in the value for defaultNum. Enter a list of comma separated branded search terms for which you are not interested in tracking phone calls as the value for brandedTerms. Enter the name of the class used for the SPAN or DIV containing your phone number on your HTML page. (Hint: you may need to create SPAN element around your phone number for this. I did and named it ‘tele‘.)

JS For Call Tracking

Step 2: Paste this JS code at the footer of your HTML page, and underneath the Google Analytics tracking code snippet. Make sure and update the path to where this file will be stored.

<script type="text/javascript" src="your/path/to/displaynumbers.js"></script>
<script language="javascript">
    displayTextNumber();
</script>

Step 3: Upload displaynumbers.js to your server. Also upload the HTML file you just edited to include the JS as well.

THAT’S IT! You are all done!! Congratulations!!!! Go to a search engine, type in a non-branded term for which you rank, click the search result and you should see your designated phone number for that search engine on your web page! This JS script can also easily be configured to swap out images and images used as backgrounds of a CSS class. The JS script could also be configured to work with PPC and other referrer types as well farily easily.

I hope you enjoyed creating your own phone call tracking application and that it brings you a wealth of knowledge about your phone call conversions.

Bonus Tip: You may want to configure conversion tracking for calls/* in  Google Analytics. This way you can see as a conversion goal how many phone calls you received as a result of non-branded organic search.

Mike, is the founder and director of search marketing of seOverflow, your strategic SEO outsourcing partner.

Connect with Mike Belasco

Mike Belasco on Linked In Mike Belasco on Linked In Mike Belasco on Twitter

17 Responses to “‘Roll Your Own’ Phone Call Tracking Program – It Is Easy!”

  1. [...] humble opinion, with over four years experience working in the Denver/Boulder SEO market, the best Denver SEO Company is SEOverlow. The company is run by Mike Belasco, who you can find speaking at local and national search [...]

  2. Mike,

    Thank you for recognizing Ifbyphone as one of the excellent Call Tracking platforms out there. We’re glad to see your firm is continuing to push the call tracking envelope!

    I’d certainly be interested in hearing your thoughts on my recent blog post about “7 Phone Call Tracking Tools Every Online Marketer Must Know”: http://public.ifbyphone.com/blog/7-phone-call-tracking-tools-every-online-marketer-must-know

    Best,

    Elan
    Ifbyphone, Inc.

  3. Jeff Lawson says:

    Hi Mike,

    Great writeup, and thanks on behalf of the Twilio community for open sourcing the whole thing!

    Regards,

    -jeff

    Co-Founder
    Twilio.com

  4. Tom Fabian says:

    Thanks for posting this “how to” for call tracking. It looks like it will be very useful to a number of our clients.
    Tom Fabian
    Frontera Interactive

  5. Nick Wilsdon says:

    Awesome article, thanks for sharing that. It’s a pity Twilio is limited to US phone numbers – does anyone know of a similar service that works internationally?

    @Jeff – or are you planning to expand to more countries? Would love to use your service!

  6. [...] seOverflow: Roll Your Own Phone Tracking Program – It is Easy [...]

  7. Our company, CallSource, invented the call tracking industry nearly 20 years ago. These days, tracking and recording calls is easier than ever. For most businesses, though, the challenge is analyzing the data and reacting to it in a way that improves their marketing, sales, and customer service. Our business is built on metrics, but emphasizes the tools and knowledge to help clients get the financial results they are after. Your do-it-yourselfers could pick up some useful ideas for free at our Website, www.callsource.com.

    Thanks!

    Elliot

  8. Zack Katz says:

    I use Vonage already, so I would be more likely to use Vonage.com features, including click-to-talk and a call log. Their toll-free numbers are $4.99/month, and I imagine you would be able to see who called from what number.

    It’s nowhere near as complex an offering as Twilio, which seems very robust, but it’s simple.

  9. Zack Katz says:

    You can also do a virtual phone number to be able to receive local calls from anywhere in the world for the same cost as an 888 number.

  10. Tim Gorski says:

    Hi Mike -

    I just wanted to thank you fro a great couple of sessions at the local search summit in chicago. You were one of the few presenters that were absolutely commited to “giving us something we could take home” … if only ALL presenters were as focused and committed on that goal!!

    Unfortunately, your presentation, like many I attended, was not available online. And even if it was, I’m sure it wouldn’t have included the necessary amount of detail.

    I was particularly interested in your presentation on how to track local results listings in google analytics using their new campaign URL builder. I wrote like hell to try and capture the procedure, but failed miserably.

    Is there any way you can post that procedure online or provide a link to the detailed procedure?

    It would be greatly appreciated!

    Thanks, again, and GREAT JOB.

  11. Mike Belasco says:

    @zack That would be cool, but keep in mind this solution also records the calls, sends you an email and records a conversion in analytics. Can’t really do all that with Vonage, but basic call tracking would be possible. Still could use our front end code provided here.

  12. Mike Belasco says:

    @tim thanks for the compliments I appreciate it! You can find the full instructions for tracking local search traffic from the ‘pack’ on our blog here: http://www.seoverflow.com/blog/local-seo/google-analytics-for-local-search-part-1-of-7-tracking-traffic-from-the-10-pack/

    Good luck and thanks again!

  13. This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine.

  14. Mollie Moore says:

    I love seeing these advances in call tracking! One company I know that has taken this basic technology to the next level is Phonalytics, LLC. Unique phone numbers are assigned to each marketing campaign to dynamically change the phone number, but all tracking is reviewed in an easy to use web-based interface that does not need to be integrated with Google Analytics. You can listen to all calls and run state-of-the-art speech analytics to monitor staff and customer moods, tone, enthusiasm, etc. A URL generator and reporting is built into the same interface, so everything is in one place. AND they’re giving away free 90 day trials like hot cakes. I can’t wait to see the effects dynamic call tracking has on the industry!

  15. Randy Z says:

    Is there a way to apply variables for PPC google, msn, and yahoo. Maybe trigger it with a URL variable like “?tr=MSN”. I need to track PPC traffic and differentiate it from natural search and original phone number.

  16. Mike Belasco says:

    Hi Randy,
    The best way to customize this for PPC is to add variables to your destination URLs. With that you can edit the displayNumbers JS and other functions to not only pull numbers for various PPC search engines, but different numbers on the campaign level too. This used to be expensive with Twilio however, numbers have now been reduced to $1 each per month.

  17. Randy Z says:

    Mike, would you be able to post specifics on how to do this?

    Thanks

Leave a Reply

Stay Informed:

  • AddThis Social Bookmark Button
  • AddThis Feed Button