Google AdWords and Google Analytics are a match made in heaven. They share data about audiences, report to each other on goals and conversions, and create rich data together in Multi-Channel Funnel reports. But not every relationship is perfect.

It turns out that AdWords doesn’t always share everything and it has a predisposition for secret phone calls. We’re hopeless romantics here at SearchStar, and we hate to see this delightful duo in disarray. So, we knuckled down for some digital relationship counselling and found a harmonious solution.

Why Track Calls?

For many of our clients, phone calls are essential to their business and their paid advertising often results in a customer picking up the phone. Using AdWords’ built in phone call tracking we measure these offline conversions and link them back to media spend at an individual keyword level. This is valuable data when we’re optimising campaigns in the platform and deciding where to spend media budget.

However, when it comes to reporting on calls we hit a bit of a roadblock. Google Analytics enables us to view Paid Search activity against the context of whole website performance and it’s our go-to tool for reporting to clients, often coupled with Google Data Studio. Unfortunately, the all-important calls that have been tracked by AdWords are nowhere to be seen. This leaves us with a missing piece to the puzzle when presenting weekly and monthly results, and doesn’t bode well for our star-crossed lovers.

The Solution

So, how do we manually upload a goal completion to Google Analytics? Straight away our minds turn to the Google Analytics Measurement Protocol, and AdWords Scripts. These two valuable components of GA and AdWords, respectively, allow us to repair the rapport between our digital lovebirds.

Within the script we first need to run a report that returns how many calls were tracked on the previous day. It then needs to construct a Measurement Protocol Hit for each call containing information about which campaign it came from. Using the URL Fetch App, we can send each of these Hits to GA as Events. The last step is creating an Event based goal in GA and hey presto, relationship rescued! Just call me Marje Proops! (Google it kids)

Below is the full AdWords script we wrote, and set up to run in the account at 2am every day.

/* Created by Analysts at SearchStar. Written by Sian Miller, @sianmiller141 *

* AdWords Call Tracking in Google Analytics - Runs campaign performance report for the previous day, and returns the number of "calls" tracked and which campaign they are attributed to. *

* This data is sent to GA via the Measurement Protocol in the form of an Event. Set up an event based Goal in GA using your parameters (conversion name). *

* Set this script to run daily at 2am. *


function main(){

//variables for report

var dateRange = 'YESTERDAY';

var columns = ['CampaignName','ConversionTypeName','Conversions','ConversionValue'];

var columnsStr = columns.join(',') + " ";

//run report

var reportData =

'SELECT ' + columnsStr +


'WHERE ConversionTypeName CONTAINS_IGNORE_CASE "calls" ' + //filter to just conversions with "calls" in the name, adjust this to match your conversion names

'DURING ' + dateRange);

var rows = reportData.rows()

//function to create random UUID

function uuid() {

return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {

var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);

return v.toString(16);



//variables for measurement protocol

var GAID = 'UA-XXXXXX-X'; //replace this with your GA Property ID

var campaignSource = 'google'; //ensures the GA goal is attributed to Google

var campaignMedium = 'cpc'; //ensures the GA goal is attributed to paid search

var eventCat = 'adwords%20conversion'; //change this to edit the Event Category, maintaining URL Encoding

var postURL = '';

var queueTime = 12600000; //3.5 hours in milliseconds so we can send the data at 2am and it is assigned to the previous day

//loop to build measurement protocol from each row of report data

while (rows.hasNext()){

var row =;

var campaignName = encodeURI(row['CampaignName']); //encodes for use in URL

var conversionType = encodeURI(row['ConversionTypeName']).toLowerCase(); //encodes for use in URL and makes them lowercase to match existing GA event structure, change if necessary

var conversionCount = Math.round(row['Conversions']); //round the number of conversions to a whole number, remove rounding if you are using a fractional attribution model

var conversionValue = row['ConversionValue']/conversionCount; //the value of each individual conversion - *on the assumption that all conversions have the same value

//for each conversion, create & send measurement protocol

for (i=0; i<conversionCount; i++){

//generate random client id

var clientID = uuid();

//construct measurment protocol payload

var payload = 'v=1&t=event&ni=1' +

'&tid=' + GAID +

'&cid=' + clientID +

'&cs=' + campaignSource +

'&cm=' + campaignMedium +

'&cn=' + campaignName +

'&ec=' + eventCat +

'&ea=' + conversionType +

'&ev=' + conversionValue +

'&qt=' + queueTime;

//log URL for debugging


//send measurement protocol

var options = {

'method': 'POST',

'payload': payload






/* Be aware that this script causes “fake” traffic to be sent to your GA profile *

* This can inflate the number of users tracked, cause sessions per user to decrease and cause the percentgae of new sessions to rise. *

* Exclude this “fake” traffic using a user based segment when reporting on these metrics. *


Feel free to copy and paste our script into your AdWords accounts to start tracking calls in Google Analytics. You’ll find the option to create and manage scripts under Bulk Operations in the AdWords menu. Just remember to tweak the script for your GA Property ID and your conversion names.

Now, with our call data being tracked in Google Analytics as Events, we can create an Event-based Goal to start reporting on calls as conversions. We’ve set the Goal up to match against the Event Category and Event Action. This ensures only the phone call Events are being counted.

There’s the potential to be more specific with the Event Action and split out Calls from Websites and Calls from Ads, but that data is already available in the AdWords platform. Lastly, we’ve chosen to use the Event Value as the Goal Value, because we had already set the worth of a phone call in AdWords. The alternative is to overwrite the Goal Value during this set-up phase.

A Happy Ending

One short AdWords Script and a new GA Goal is all it took to reignite the flame between these two companions. The undisclosed telephone chit-chats are no more and our monthly reports contain all of our tracked phone calls. This results in a much more joined up picture of performance.

For more information on setting up AdWords call tracking on your site, checkout our four-step guide from Nick here.

If you need any help on AdWords Scripts, Google Analytics tracking or general relationship advice, get in touch with the team by emailing