Phone Call Event Tracking with Google Analytics & Twilio Number

This article explains in a simple manner how to track phone calls and call duration with twilio phone numbers and input into google analytics (universal) for event tracking.

Step 1 – Make sure you have google universal analytics on your website

If you don’t, please install the latest tracking code or upgrade at google.com/analytics

Google Analytics Universl Code

Step 2 – Register with twilio and get a phone number

Register and login to twilio.com

Twilio

Step 3 – Create script to input into google analytics

All you have to do is add the following code to a webpage on your server.
DON’T FORGET TO:
a. change ANALYTICSACCOUNTID to your account analytics account id (“UA-xxxx-xx”)


<?php

$datetime = date('m-d-Y--H:i:s');
$call=$_GET['CallDuration'];

header("Location: http://www.google-analytics.com/collect?v=1&tid=ANALYTICSACCOUNTID&cid=123&t=event&ec=Contact&ea=Call&el=$datetime&ev=$call");
exit;

?>

Step 4 – Reference script in twilio

After you login to twilio, on main dashboard page, click on “numbers” page and click on your phone number. Under “voice” section, click on “optional voice settings” in order to open more options and add url of script we just created to “Status Callback URL” and click on “save changes”.

* see google guidelines at Google Analytics Universal – Measurement Protocol Developer Guide –https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide

Status CallBack URL

Step 5 – Test in Analytics

Make a phone call and look at the real-time events section and test over time.

Look at analytics events

Hope you enjoyed this simple video. We love twilio and analytics, especially the bridge between offline and online.

Let us know if you have any questions. We’ll be happy to help!

Video Transcription:

Hey everybody. This is Ori from Astral Web. I’m very excited to create this video to show you how we bridge the gap between the offline and online world. in this video we’re going to track everytime someone calls our phone number, we’re going to put into google analytics the duration of the call. This is a very simple example so you can understand what’s going on and you can build upon that. Very cool thing – let’s dive into it very quickly. The first thing we want to do is buy a twilio number. Twilio is a really nice company and enbales you to add programmatic addons. Go to twilio.com and register and we recommend them. After you register with twilio , login and click on phone number and go under the voice section under optional voice settings and status callback url. What that means is anytime a phone call is completed, at the end of the call it will trigger the url you specify. We will create this script in a second. The script will then take information from twilio and input it into google analytics. Very cool!

Let’s look at the file. eventtracking.php. Let’s go to our server via ftp client and edit eventtracking.php. All you have here are 3 or 4 lines. What i actually did was included the date and the time in order to track in analytics when the call was made and the GET field we receive from twilio. After you get the time and the date from the server plus you might want to adjust the time if your server time is different from you home or work computer. After that you will use the latest google analytics universal url (/collect/). If you don’t have analytics universal you will need to install on website. Let’s look at code and check if we have latest analytics universal code. You can also check in analytics in admin, tracking info and tracking code. It should say, this is the universal analytics code… It came out a few months back (as of 2013). Looking at the redirect header url, google analytics enables you to pass offline information via a collect url in a very simple manner. Now you have to insert different fields. TID is the account id starting with UA dash …. CID is just a userid and this case we don’t use it. Now we specify that we want to track an event. EC category is called contact. EA is the action is called call and the label is the date time and the value is the call duration. So anytime someone calls you at the end of the call, twilio will go to your specified url and the script will give analytics the call duration. And i’ll show you how it looks. In the events section in analytics, you’ll be able to see time of calls and durations. You can translate into minutes instead of seconds. To test, make a phone call and go to google analytics, real-time and look into events and make sure it works correctly.

If you’re running a pay per click campaign, you might want to have different phone numbers
for your landing pages or from SEO. Try to have a unique twilio number for your website, different from your regular store or other numbers for better tracking. Super simple code and works real well. If you have any questions, i’ll be happy to share and answer questions.

Check Load Speed of Webpage

In order to analyze how fast your website or specific webpage loads, you will want to use an analysis tool. We like using gtmetrix.com especially because it shows the specifics of load time and helps us find bottlenecks and issues with our site.

Step 1: Go to Gtmetrix.com

Gtmetrix Tool

Step 2: Check Website/Webpage

Enter into text box your specific webpage and click on “Go”

Step 3: Look into Data

Take a look at the “Breakdown” and “Recommendations”

Especially look into tabs

– pagespeed
– yslow
– timeline
– history

Page Speed Data

Page Speed Timeline

Video Transcription:

Hey everybody. creating another site speed tip video and just wanted to talk about how do i and webmasters, site owners figure out how fast is there website loading. one tool that we use a lot is gtmetrix.com. it’s not our site, just a simple tool. i think they do a really great job at diagnosing each part of how the site loads. so all you have to do is go to gtmetrix.com, insert your domain name. let’s insert ours for example and click on go. it’ll fetch the page and then figure out what’s taking time and give you some information about how long is it loading, what are the specific parts and what can you improve. so you can take those guidelines and improve the site in general. so once i did this i put our website right here and it gave us a page speed grade of a 96% and y slow page grade of b. and it tells us that the entire website with css and javascript loaded in 2.7 seconds. the total page size size including all external pages, html, javascript and css and there were 47 different files including php and css. so this is how long the website took to load, 2.7 seconds. and you know maybe this is sufficient for you or not but if you go down here, there are 4 tabs and it’ll tell you what you’re scoring in each of the things, and of course try to improve the ones that you have bad grades. one example of speeding up website load is instead of having separtae images you can combine some of them in css sprites and have multiple in one so the browser fetches less images. the next tab is yslow, and on and on. so you can see all of these improvements to do and the other thing i really like looking at is the timeline and that shows you how long ever single file took to do fetch and not just how to fetch but also each component of dns, server wait and transfer. so you can see the php file, the index file, took .1 seconds and on and on. and you can figure out if you have 404’s or specific very large files or take a long time to download. hope you enjoyed this. thanks!

Google Browser Size Tool

All web designers today must pay attention to additional aspects such as SEO and conversion data.

See Google Browser Size Tool to get a better idea about what users can actually see without scrolling (numbers ofcourse don’t include less space taken from toolbars and funny browser bars)

Oh, users can only see first row of 3 products without scrolling

Enjoy!

Nofollow Chrome Extension

See Astral Web’s Chrome Extension for easy to find out nofollow links on any page.

Description – Hover over a webpage link to discover if it is a follow of nofollow link. Great for SEO work & link building. Utilizes robots.txt, meta robots tag and rel for nofollow diagnosis. Currently does not work with javascript links.

Get nofollow chrome extension