How to track phone calls using a simple Google analytics solution.

Author: +
Posted on: May 18th, 2012 Posted in: Web Analytics
There are a number of solutions available on the market to track phone calls derived from your online marketing campaigns. One example is AdWords Call Metrics, another even more comprehensive solution is AdInsight. Both are great solutions in their own way, as they give insights on phone calls down to the keyword level, but they have their drawback. First of all the extra cost they incur. Secondly, AdWords Call Metrics won’t allow you to track premium rate numbers. If a client’s business is based on profits on premium rate numbers, or if they can’t afford or don’t want to pay extra money for call tracking over the regular online marketing costs, you will have trouble measuring the success rate of the campaigns. We at BD had needed to come up with a solution that is free, and gives at least the minimum level of insight into what parts of our campaigns generate the most premium rate phone calls and at what CPA. In this blog post we will introduce our custom-made solution to this problem. We managed to track the calls and assign them to our campaign down to the ad group level.

How it works.

We track the phone calls in a dedicated Google Analytics profile as visits by loading a URL with Google Analytics utm tracking parameters. We need to do it in a separate profile from the main profile of the website, otherwise this tracking would artificially inflate the number of website visits and bounce rate which we definitely don’t want. The client’s call services are accessible through BT premium-rate numbers. They set up unique phone numbers for each of their traffic channels, including direct traffic, organic search, SEM, Facebook, etc. Their SEM channels are further broken down to several phone numbers. They have a unique number for each ad group, and each ad group has its own landing page where the appropriate number is displayed. In total, we are talking about 110 unique phone numbers. Our solution records call data associated to ad groups into Google Analytics through the following steps:
  1. A comma separated csv file is generated from SQL data via BT which includes all the phone numbers from which calls were received. The csv is generated on a daily basis at the end of the day.
  2. The csv file is sent to a dedicated e-mail address every day a 0:05 am.
  3. The dedicated e-mail address is constantly monitored by a desktop application developed by Barracuda Digital which is running on our servers. The application downloads and reads the e-mail attachment, summarizes the number of calls for each number (Ad Group), then it loads generates a url with the appropriate utm_source, utm_medium, utm_campaign and utm_content parameters based on a predefined config file, then visits a page we set up for that URL in a JavaScript-enabled browser.
  4. The page we set up on the URL is a simple html page containing a customised version of the Google Analytics tracking code which records each page view as a new visit to the site with the appropriate campaign parameters.

The structure of the call data file

The format of the csv file generated on the client’s side is very simple and straightforward. It’s a comma-separated csv with two “columns”, one represents the phone number called, and the other one represents a value of “True” or “False” depending on whether the call was from a new unique caller number or not. The client is only interested in new unique callers therefore this is what we measure as acquisitions. An example row of the csv file could be the following:
02079655555,True

The Desktop Application

We found that with our current developer resources the easiest way we can constantly monitor an email address and download messages and attachments is by utilizing Java open source libraries. The challenge was that we found it difficult to view a webpage within a Java application AND run JavaScript on the page at the same time. However, it was a requirement for Google Analytics tracking. Our solution is currently a combination of a Java application and a C++ application as we found it much easier to create a simple browser in C++ for the purpose of loading our URL’s. The way it works is that we have our Java application running 24/7 on a Windows server. It
  • checks the mail on the dedicated email address in regular intervals
  • downloads any csv attachments found in the emails
  • looks at the list of phone numbers in the csv file and summarizes the number of acquisitions for each number
  • it generates URL’s with the appropriate campaign parameters based on a config file we created in advance
  • it calls our C++ app with the list of URL’s which in turn loads all the URL’s generated
  • it closes the C++ app when it finished downloading the URL’s and continues to check for new emails.
  The C++ application basically loads the list of URL’s it’s given one by one with 10 second intervals between each page view. The 10 second delay is just a precaution, as we set the GA visitor and campaign cookies’ lifetime to 1 millisecond. The config file The config file of the Java app is a csv which includes an index of all the phone numbers with the corresponding utm-tagged URL. Each row consists of a phone number and a URL with the utm parameters for the corresponding campaign/ad group. The URL of course itself is always the same, but the campaign parameters are unique per ad group. Following is an example row from the config file:
8715500129,http://barracudadigital.co.uk/c_track/index.html?utm_source=Google-PPC&utm_medium=Phone&utm_campaign=CampaignName&utm_content=Ad%20Number%20Called
As you can see, the campaign medium is set to Phone, and we included the indication that it is a PPC campaign in the utm_source parameter. One of the reasons we decided to do this is to make it visually clear to anyone looking at the report that these visits are not ordinary visits but phone calls.

The tracking code

As our method is based on tracking calls as visits, we couldn’t use the main Google Analytics profile of the site because it would have distorted the real website traffic data. We set up a separate profile for call tracking instead. The tracking page is hosted on the barracudadigital.co.uk domain. The source code of the page is as follows:
<html>
<head>
<script type=”text/javascript”>
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17976637-2']);
  _gaq.push(['_setSessionCookieTimeout', 1]);
  _gaq.push(['_setVisitorCookieTimeout', 1]);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body>
Test Page
</body>
</html>
    We made two customizations on the code:
  1. We set the session cookie expiration time to 1 millisecond.
  2. We set the visitor cookie expiration time to 1 millisecond.
These customizations were made in order to make sure that every pageview made by the desktop application is recorded as a new visit by a new unique visitor.

Filtering out inappropriate traffic

We had to take into consideration the possibility that someone accidentally loads the page  set up for the call tracker, and it gets recorded as an extra visit. We have hidden the page from search engines in the robots.txt file on our webserver, however, it is still not a fail-proof solution. To make sure we only see the real acquisition data when looking at the reports, we have set up an advanced segment. The dimension we used for filtering was the medium, as it is always the same, ‘Phone’ for all of the advertising channels. We  also set up an ip addres filter in the profile which would filter out every non-Barracuda IP addresses. As our call tracking server is on our internal IP address, that should prevent any outside source to mess up our call data. The results After just a few day data started to accumulate nicely in the GA profile. An example screenshot of the report layout with campaign names blurred out is below.   We use the Campaigns report with the pivot table view in order to view 3 dimensions (source, campaign, and ad group) in one table. We finalized this project by creating a custom report through the Google Analytics API which also pulls both cost data from the main website Google Analytics profile and call data from the call tracking profile into one excel file that then calculates the CPA of each individual ad group.

NOTES

1.   As data from a certain day is recorded in the early hours on the next day, there is always a one-day offset in the data shown by Google Analytics. It had been explained to the client prior to implementing the system and both we and the client take it into consideration when looking at the reports. Also, in the final automated report which merges data from the two Analytics profile, we take this factor into consideration so the right cost and call data is attributed to the right dates. 2.   As seen on the screenshot above, some ad groups are named ‘Ad Number Called’. These are not actual ad groups. This is because there is a campaign level phone number for each campaign which is included in the ad copies. These calls are basically “free” calls that were not preceded by an ad click.

Business Impact

Before our call tracking solution was implemented, the client sent us their call and acquisition data extracted from SQL through BT’s system in a csv file which we then used in our weekly PPC reports. However, the process was very manual and time consuming, and there were lots of room for human error. It took considerable time and effort from both sides to create the reports because of the high number of phone numbers set up for the account. Since we implemented GA call tracking, both the client and Barracuda Digital saves time on a weekly basis, allowing us to spend more time on optimizing the campaigns rather than reporting. We also minimized the possibility of human error as the whole process is automated now. Moreover, call data is now presented in Google Analytics in a more spectacular and meaningful way, across wide date ranges when necessary, and can be easily exported into pdf or other formats.

Leave a Reply