How to Send Call and Campaign Data from Marchex to Google Analytics

We recently switched to Marchex for call tracking. With Marchex, we hoped to be able to attribute calls to the source, medium and even keyword.

Marchex has a Google Analytics “postback” feature which will send a pageview to Google Analytics. We can specify the URL. However, it’s not possible to send any kind of tracking data (including URL parameters), via the URL or otherwise, directly to Google Analytics. (You can include URL parameters in your URL, but they won’t do anything. Google will only receive the path.)

Initially, we tried to work around this by specifying the source and medium as part of the path (e.g. http://domain.com/source/medium/). Obviously, Google Analytics isn’t going to identify and extract the source and medium from a URL like that. And that “workaround” never really satisfied me.

But wait!

Marchex has a “postback” feature that posts a ton of juicy call data. You can send this POST to any URL you want. And… you can include URL parameters.

It occurred to me… I could write a script that will receive the Marchex POST and then send the data to Google Analytics using the new Universal Analytics and the measurement protocol!

Duh!

So, that’s exactly what we did. And it works like a charm. Want to see how we did it?

First, read this post on tracking campaigns with Google Analytics measurement protocol.

Next, take a look at the data that Marchex sends via their post.

ArgumentDescription
accUnique Account ID
grpUnique Group ID
cmpUnique Campaign ID
callUnique Call ID
called_numberPhone Number Called
caller_numberPhone Number Called From
caller_nameName of Caller (per Caller ID info supplied)
call_startStart Timestamp of call
call_endEnd Timestamp of call
keywordKeyword call was assigned to (if you have the “Keyword-Level Tracking” package)
recorded_pWas the Call Recorded
call_statusCall Status (ANSWER, HANGUP, VOICEMAIL, or OTHER)
forward_noForwarding Number
assigned_toUser call assigned to
answer_offsetSeconds of Playfile and Ringing
ring_durationSeconds of Ringing
inbound_extInbound Extension
lookup_nameCaller name from Reverse Lookup
lookup_addressCaller address from Reverse Lookup
lookup_cityCaller city from Reverse Lookup
lookup_stateCaller state from Reverse Lookup
lookup_zipCaller zip from Reverse Lookup

You could potentially grab any or all of this data and send it to Google Analytics using custom dimensions and metrics.*

Suppose you wanted to track the city from which the call came. You could create a custom dimension for “city.” If you were doing this in PHP, you’d simply do something like

<?php $data['cm1'] = $_POST['lookup_city']; ?>

Alternatively, although I haven’t tried this, it might be possible to spoof an IP address from the caller’s city, state and zip. The way I imagine this would work is by having a database of IP ranges for U.S. cities, states and zipcodes. Then you’d attempt to send the IP address through the cURL HTTP header option like this:

<?php curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip")); ?>

 

Finally, as I mentioned earlier, in Marchex’s system, where you set the URL to which you’d like them to post all this juicy call data, you can also include URL parameters. This means that you can also identify the source and medium (if you’ve created a Marchex ad campaigns for specific sources/media). Here’s an example of how a Marchex “Postback URL” might look.

http://targetclickmarketing.com/mp?ga_acc_id=UA-98765432-1&domain=whatever.com&path=%2Fphonecall&page_title=Phone%20Call&utm_source=google&utm_medium=cpc

Once you’ve done all that, all that remains is to send phone calls and check out all the cool data in Universal Analytics property you’ve set up in Google Analytics.

* FYI: It’s against Google’s Terms of Use policy to import personally identifying information. So, don’t go sending things like the caller’s name, address, phone number, etc. to Google Analytics. That could land you in hot water with Google.

Leave a Reply