Hello;
We are trying to find out how to track keywords associated with our mobile searches. Third party companies such as CallRail and CallTrackingMetrics have built Google Adwords Mobile Click to Call integrations which "match calls with clicks" in an effort to report the keywords associated with calls in call-only ads and mobile campaigns that have mobile only call extensions.
Here is the information from CallRail re: what we are trying to build
Here is an example script being used by CallTrackingMetrics to Pull in Keyword data from call only ads. *I can verify that the below code is not 100% accurate as the keywords being returned are not in alignment with what I see in AdWords.
/* Copyright 2016 CallTrackingMetrics LLC */ function filterByCallType(e,a,t){"Mobile click-to-call"==a?e.Device.match(/Mobile|Tablet/)&&t():t()}function criteriaReport(e,a,t,r,l){for(var o=[],i=r.within.start.slice(0,8),C=r.within.end.slice(0,8),n="DURING "+i+","+C,d="SELECT Id, Device, Criteria, CriteriaType, Clicks, Impressions, CampaignName, CampaignId, AdGroupName, AdGroupId, AdNetworkType2, ClickType, Slot, QualityScore FROM CRITERIA_PERFORMANCE_REPORT where ClickType=CALLS AND Clicks > 0 AND AdGroupId='"+e+"' "+n,c=AdWordsApp.report(d),p=c.rows();p.hasNext();){var g=p.next();filterByCallType(g,t,function(){g.CallType=t,Logger.log("captured("+r.id+") of type: "+t),o.push(g)})}return o.length||o.push({KeywordId:l.Id,CampaignName:l.CampaignName,CampaignId:l.CampaignId,AdGroupName:l.AdGroupName,AdGroupId:l.AdGroupId,CallType:t}),o}function ctmFetch(e,a,t){var r={contentType:"application/json",headers:{Authorization:"Basic "+Utilities.base64Encode(CTMKEY+":"+CTMSEC)},method:a};t&&(r.payload=t);var l=UrlFetchApp.fetch(CTMHOST+"/api/v1/accounts/"+CTMACT+"/calls/"+e,r),o=l.getContentText();return Utilities.jsonParse(o)}function fetchCallData(){var e=AdWordsApp.currentAccount().getTimeZone(),a=ctmFetch("ad_extensions?tz="+e).calls;Logger.log("running analysis for : "+a.length+" calls");for(var t=0,r=a.length;r>t;++t){Logger.log("fetch for "+t+" < "+r);try{var l=a[t],o=lookupDataForCall(l);o.length?(Logger.log(" Criteria Id CriteriaType Clicks Impressions CampaignName AdGroupName ClickType Criteria"),Logger.log("trigger data for "+t),Logger.log(" Send data for: "+l.id+" matched: "+o.length),ctmFetch("possible_keywords?id="+l.id,"post",JSON.stringify({captured:o})),Logger.log("still active?")):Logger.log("no adwords calls detected for: "+l.id)}catch(i){Logger.log(i)}}Logger.log("exit loop for "+t)}function lookupDataForCall(e){var a={972:!0,33:!0},t=e.areaCode;a[e.countryCode]&&!t.match(/^0/)&&(t="0"+t);var r="SELECT AdGroupId, AdGroupName, CampaignId, CampaignName, CallStartTime, CallEndTime, CallerCountryCallingCode, CallerNationalDesignatedCode, CallType, CallStatus, CustomerDescriptiveName FROM CALL_METRICS_CALL_DETAILS_REPORT WHERE CallerCountryCallingCode='"+e.countryCode+"' AND CallerNationalDesignatedCode='"+t+"' AND CallStartTime >= '"+e.within.start+"' AND CallStartTime <= '"+e.within.end+"'";Logger.log("Query for "+e.id+" with "+r);for(var l=AdWordsApp.report(r),o=l.rows(),i=[];o.hasNext();){var C=o.next();if(Logger.log("Phone Call:"+C.AdGroupName+" "+C.CallStartTime+" "+C.CallEndTime+" "+C.CallerCountryCallingCode+" "+C.CallerNationalDesignatedCode+" "+C.CallType+" "+C.CallStatus+" "+C.CustomerDescriptiveName),i=criteriaReport(C.AdGroupId,C.CallStartTime,C.CallType,e,C))return i}return i}function main(){fetchCallData()}var CTMHOST="https://api.calltrackingmetrics.com",CTMACT=103975,CTMKEY="a103975d0a444cea7323b01b45e40216b5c0dda7",CTMSEC="a38881d623f53aefafdb13a079621c05b941";
Can anyone help me understand how to pull in keyword data based on calls coming from call only ads? These ads use phone numbers provisioned by Twilio. We are currently tracking start time / end time / call duration / caller_id / geo based on NPA-NXX data /etc.