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

  1. You can either use a regular number or a tracking number for your website and all local citations… but you are committed to keeping that number…

    Then you can serve a different number based on the referring url (which google bot won’t see) to track each marketing channel.

  2. Hey There,

    can you please tell me is it possible to track call start and end time after operator is redirected to the given number on instructions of IVR ?

  3. Hi- a dental client of mine is looking to implement this tracking strategy. Do you know if this is HIPAA compliant?


  4. By setting up multiple phone numbers, doesn’t this hurt your local rankings? Google Places looks for consistency in NAP (name, address, and phone number). So you need to be very careful not to diminish your ROI in those other channels that depend on a phone number being consistent.

  5. Mike,

    This is pretty awesome. I’ve been using Voicestar (Marchex) and it gets pricey at $25 a number so this is a great solution. Thanks for this post.


  6. First of all great resource Mike… Second, not sure what I may have done wrong but the call source does not show up in my emails it just says “0” does anyone know how to correct this??? Thanks in advance for your help!

  7. Hi, I am really interested in this, but maybe I am missing something here, how can the cookie be read in the js file if it has just been set for the first time by the google tracking script on the same page.

    • just make sure the Google call happens before the call tracking JS and you should be fine

  8. How can we implement “call whisper” into this script? So, that when the call is forwarded the person answering the phone hears a quick customer greeting?


      • That is of course possible. You need to add a Play verb at the top of the script. If you want to use a pre-recorded audio or a Say verb if you want to use default twilio machine voice.

        Actually, more sophisticated calling app is possible with twilio/tropo. if you need any help feel free to ask.

  9. Great article. I’ve really been wanting to do this but BLOWN away at the cost of commercial solutions.

    If possible, could you clarify the ‘branded keyword’ part? What is that & and what is it for, exactly? … I assume it is either to restrict tracking to ‘branded’ terms or eliminate tracking on ‘branded’ terms. I can imagine people not wanting to track people who searched for the full domain name, for example. … Thanks for any mroe info you can provide.

    Also, I think it would be handy to have an additional ‘catch all’ phone number. In other words, something that would register calls if they were anything other than the main variables (google, bing, etc). Do you know a simple way to accomplish this?



    • since we are an seo company we are focused on getting ‘new’ potential customers to our clients. Typically if a potential customer searches with a ‘branded’ term like a company name or key person’s name, they already know of our client and we wouldn’t want the “credit”

  10. This is a fantastic tutorial, but for those who prefer not to roll their own system, we’ve launched CallRail (https://www.callrail.com). We offer instant phone number setup, javascript-based dynamic number insertion and Google Analytics integration. It’s priced right for small businesses and independent marketing consultants.

      • Yes, CallRail is built on the Twilio platform. We may consider adding more providers down the road, but Twilio has been a robust and responsive telephony provider with an excellent inventory of available numbers.

  11. I’m building basic web sites based on WordPress themes for local businesses in Canada. I’m looking for someone to make it easy for my clients to implement call tracking as described in the article above.

    I’d be willing to pay a small fee for someone who can help us implement call tracking.

    email me your name and phone if interested.

    send it to my yahoo address:

    yahoo username: jfmlists

  12. Thanks for this great resource guys. This post has really been helpful.

    I am running into a bit of a problem however with your code as the callsource is not passing through.

    I quadruple checked the code based off what you mentioned above.

    I even tried this on multiple domains, a Drupal site and a WP site, no luck.

    Both are returning 0 as the callsource.

    I actually just tried moving:

    $callsrc = $_GET[‘callsource’];

    from the handler.php to the twiml.php file and it seems to work now.

  13. Okay I figured it out. My keywords were 2-3 words so they had spaces in them. When you input your branded keywords into the displaynumbers.js file you need to put for each space. Once I did that, it started working correctly. Makes sense to me.

  14. FYI, I also tried with spaces and commas in addition to just commas (as the comments specify). Basically its doing this:

    if the first branded kw: doesn’t do any sub, shows the number in the code (CORRECT)

    if the second or other branded kw: subs out the number with the non-branded search number even though this is a branded kw (ERROR)

    if a non-branded kw: subs out the number with the non-branded search number (CORRECT)

    if referral: subs out the number with the “default” number (CORRECT)

    By the way I’m being way rude here too. Thanks so much for doing all the work on this and providing it at no cost. I shall be hooking you up with some links which is the least I can do 🙂 I realize you owe us nothing here and have already provided a great value at no cost to those of us who are implementing this.

  15. Cool. I look forward to seeing that!

    Also, the current version for us isn’t working for the branded keywords. It only filters out the first branded keyword in the list. For example:


    In that scenario, it will identify the first as branded and thus use the default number, but for the second and third its treating them like non-branded organic search referrals. Any thoughts?

  16. Mike,

    Thanks for this quite useful piece of code. Before I can implement it, however, I would like you to please answer a nagging question I have dancing in my mind. Here it goes:

    MANY LOCAL SEO experts (including you, of course) recommend consistency in the basic listing info, INCLUDING the phone number. As you wrote elsewhere, “Use only ONE phone number in all references to your business, ONLINE and OFF-LINE”

    Well, the tracking system you describe here seems to go against this advice for Local SEO by offering different numbers to same business, so the question is…

    Can someone interested in Local SEO use this system safely, or will it take away from its ranking?


  17. Mike,

    First, thanks for creating this and sharing it. Quite a resource!

    Now a question, shouldn’t Step 3 above for twiml.php also have us replace “goinflow.wpengine.com” with our domain?



    • So I just made this change to the twiml.php file as mentioned above and that fixed the issue with the emails not coming through. The only other issue I was having was the goals tracking in Analytics. I think this should fix that too. I’ll have to wait a few hours though and check Analytics to be sure.

      • awesome john, glad you got it working. I’ve been trying to schedule a big blog post update on a slightly modified version of this we are now using. Should be out soon!

  18. Hey Mike!
    Your article just save me a lot of time and headaches…
    I’m glad to have found it.
    The details you gave are perfect and they work as expected except for the email part.

    In your screenshots you show what seems to be an older version of Twilio’s interface.
    I’m not sure but right now They have the option for Post and Get when you enter the URL (step 6) of the tracked information.

    In the handler.php PHP file it’s set to Post.

    Right now everything for me works except the email.
    I’ve tried different emails too…
    Would you happen to know if this php code still works with this new update in the admin of Twilio’s? Or if it would need some kind of tweaking?

    Thanks for your help and for sharing your code here…

    • Hi David,
      The email functionality does not have anything to do with Twilio. I would check with your hosting company.

  19. Hi Mike,
    this is an excellent post. Twilio also told me about a similar openVBX version which I have running – albeit not very well at this stage. But I will keep messing with it until it works smoothly.

    Just wondering: are you able to track down to the keyword level and actually know what keyword is resulting in a conversion? If I am bidding on a few hundred keywords for PPC could it tell me which keyword led to a phone call?

    • You could in theory, but you would need a different number for each keyword, and a lot more lines of code in your JS which would slow it down tremendously.

  20. Thank you, Brad. What do you mean, please? They’re on the phone … and … ?

    (Keeping in mind that asking marketing questions while they are on the phone results in a 10%-35% chance of losing the client. They are paranoid enough, when they call. We’re a criminal defense law firm.)

  21. I’m loving this tutorial I have to tell you and can’t wait to implement. I was all but giving up on the call tracking because of cost issues and then came across this. Fantastic!
    Thanks in advance Mike.

  22. Yea it isn’t getting passed at all. I am getting the “0” from the $num = 0; in twiml.php

    Also, I noticed the javascript isn’t working at all in IE…I don’t use it so it took me a while to find…lol but any idea as to why?

    Thanks for the help,


    • Chris if you want you can email me your code and I will take a look, I haven’t had those problems with IE or not passing variables….. mike at seoverflow dot com

  23. Is there a way to make the analytics customizable for each twilio number. Basically if you have multiple numbers tracking different KWs with an individual number per word or group, to show up in google as different calls.

    Like if I am tracking flooring and contractors. I tried the following unsuccessfully:

    https://www.mywebsite.com/calls/twiml.php?callsource=GoogleFlooring for one number
    https://www.mywebsite.com/calls/twiml.php?callsource=GoogleContractors for another.

    Both showed as page hits to calls/0

    Any ideas?

    Thanks for the great post!


    • Chris,
      Check that your variable for source is getting passed correctly. The URL should be diffferent and is auto created from the call source. Should be no problem. Also of course when you take this live you’ll need to modify the rules in the JS so that you are changing the number based on keyword (which is available already in the code) rather than just source.

  24. Hi Mike,
    It’s funny that I returned to this article just a few months later and read it with a completely different attitude.

    I’m looking into different services, and I am definitely intrigued by the article. Thanks for providing the source code, too – I’m going to try it out.

    • cool Zack, as you may have read in the comments, it is now even cheaper as numbers are only $1 each down from $5 each. Good luck, and let us know if you need help.

  25. Mike,

    I’m curious what drawback you found in Mongoose Metrics (except price). We’re currently using Mongoose Metrics for our clients and are extremely happy with them.

    I’ve been throwing around jacking their concept, and just using the Google analytics API for displaying the numbers, but I think it’ll be too complicated.

    There’s one thing I’d like to see before I start adding phone calls as a goal in Google analytics, and that is to get the clients browser to actually call the URL instead of having the server call the thank you page whenever a call is made.

    This can be done using one of the google analytics hacks that refreshes the javascript call every 10 seconds – https://padicode.com/blog/analytics/the-real-bounce-rate/

    If we can have it call the API (mongoose or Twilio), the clients browser can then call the URL, allowing you to pass it into Google analytics on the adwords cookie, and ultimately back to adwords as an action.

    That would be really cool and dumb for my clients 😉

    • Hi David,
      Basically Mongoose’s pricing structure (buying blocks of minutes) combined with their price, combined with the fact that everytime I spoke with them they wanted to chat about PPC (most of our clients do organic) made me want to go another direction.

      Very cool idea with your API and recording the session from the user vs the server. Would you like to spend a few minutes brainstorming this sometime with me?

  26. 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.

    • 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.

  27. 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!

  28. 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.

  29. 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.

  30. 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.

  31. 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.

    • @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.

  32. 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, http://www.callsource.com.



  33. 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!

  34. 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

  35. Hi Mike,

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




  36. 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”: https://public.ifbyphone.com/blog/7-phone-call-tracking-tools-every-online-marketer-must-know


    Ifbyphone, Inc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About The Author

A photograph of Mike Belasco on a hiking trail.

Mike Belasco

Mike Belasco has been an entrepreneur and digital marketer since 2003. Mike founded Inflow (previously known as seOverflow) in 2007 and led Inflow to five Denver’s Fastest-Growing Private Company awards and three Inc. 5000 awards. In 2009, he also founded ConversionIQ, which was subsequently acquired by Inflow. After 20 years of serving as Inflow’s Founding CEO, in 2023 Mike completed a sale of Inflow. He now takes on entrepreneurial adventures and continues to be a raving fan of the Inflow team while consulting as a Strategic Advisor. 

View Author’s Profile

Request a Proposal

Let us build a personalized strategy with the best eCommerce marketing services for your needs. Contact us below to get started.

Send this to a friend