Situation Report

Call Tracking with Twilio & Google Analytics using Twimlbin

Nearly a year ago, I was working on a new feature for an app powered by Twilio when I realized that it would be significantly easier to get started with Twilio’s TwiML if hosting an XML file could be removed from the equation. Several weeks ago, Twimlbin was born. One of the features we needed to implement quickly was the ability to track calls both as a pageview and an event in Google Analytics. After building this feature, we found it more and more useful for many other call tracking instances. With this feature and the TwiML <Redirect> secondary verb, it’s possible to use Twimlbin as a basic analytics proxy – something we find incredibly useful.

How to setup Call Tracking

Simply create a new Twimlbin and set it to redirect to either a number directly or your script or you can clone one of the example bins we’ve provided.

For a Number: Clone this bin and replace the number with your own.

<Response>
  <Dial>415-867-5309</Dial> 
</Response>

For a Script: Clone this bin and replace the URL with your app’s location.

<Response>
  <Redirect>https://example.com/twilio_app.php</Redirect> 
</Response>

Once you’ve setup the Twimlbin, simply put in your Google Analytics ID (near the bottom of the page) and you’re ready to go. You can even watch calls in real-time with the new Google Realtime Analytics feature.

twimlbin analytics calltracking

We hope you enjoy Twimlbin as much as we do. Tweet @TwimlBin if you have questions!

About Jonathan Kressaty

Partner and co-founder at Vuurr. Our clients know him as the brain behind all their development dreams.

Remarks

    • Right on, thanks for commenting. Let us know if you have any questions about Twimlbin and feel free to share it around – we haven’t promoted it a ton yet but we use it a lot on internal stuff and client projects; so… Enjoy!

  1. I am using single PHP page for generating response for about 30 clients. And all the responses are different. i am using API to make call.
    My Question is
    How can i make a twiliobin for each number using php
    How can i push the data to google analytics using php
    Is there any API for that?

  2. Hi, I was looking into this, but I’m not sure how to get started. I have existing Twilio #’s. What do I put in the “TwiML” if I just want a simple call tracking added in google analytics?

    • In the article, click on the link to clone the example Twimlbin. In the clone, there is a box near the bottom of the page called “Track Calls & SMS with Google Analytics” where you can simply enter your GA account number and choose from the drop-down how you would like the call tracked. I track calls as pageviews because that makes it easy to set them up as goals in Google Analytics. As far as the actual Twiml goes, you will want to use the verb and use it to dial the the number of the phone that you want to ring. Here is a link to the documentation on the verb: http://www.twilio.com/docs/api/2008-08-01/twiml/dial.

Comments are now closed but you can still reach us via our contact page.