Google Ads Script to Set Radius Targeting in Bulk
AdWords Editor does actually support proximity targets where you set the radius targeting of your campaigns via uploading the longitude and altitude in a specific format. However, a common issue that you might face when adding your location targets in bulk is “Unresolved Location” where the editor doesn’t recognize the areas’ addresses. This might result in failing the completion of importing all location targets.
On the other side, AdWords scripts are more powerful in creating proximity targeting where most target points go through without any errors as long as all info is accurate. Moreover, you can automate the process of updating your radius targeting by scheduling the script to run on a frequent basis based on your needs.
Accordingly, we’ve written a simple AdWords script that connects to Google sheets where you provide campaign names and the necessary location arguments ( Latitude, Longitude, Radius, Radius Unit).
#Latitude: The latitude of the central point.
#Longitude: The longitude of the central point.
#Radius: The radius of the proximity target.
#Radius Units: The units of the radius, either “MILES” or “KILOMETERS”.
After you create and fill your sheet with all the details, it’s time now to add the spreadsheet URL in the script source and run it.
/********************************************* * Radius Targeting Script * Version 1.0 * Created By: Ahmed Ali *https://optimizationup.com/ **********************************************/ function main() { var SPREADSHEET_URL = "INsert your spreadsheet URL here"; var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); var sheet = spreadsheet.getActiveSheet(); var data = sheet.getRange("A:E").getValues(); for (i in data) { if (i == 0) { continue; } var [CampaignName, latitude, longitude, raduis, unit] = data[i]; if (CampaignName == "") { break; } else { var campaignIterator = AdWordsApp.campaigns() .withCondition("CampaignName CONTAINS_IGNORE_CASE '" + CampaignName +"'") .get(); while (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); campaign.addProximity(latitude, longitude, raduis, unit); } } } }
Entrepreneur focused on building MarTech products that bridge the gap between marketing and technology. Check out my latest products Marketing Auditor & GA4 Auditor – discover all my products here.
This is awesome. One note, I tried running the script using the link from the 7th or 8th tab in a Google doc and the script ran, but didn’t make any changes. I made a brand Google doc and put everything on the first sheet and it worked perfectly!
This is an absolute lifesaver. Had to setup 140 office locations with 10km radius targeting and this worked a treat, thank you!
This is saving me TONS of time! Thank you so much for developing this script. I can’t believe it’s not native to Google Ads interface – especially after they updated it recently.
Hello Ahmed,
I want to change the heading 2 based on radius location? Is there any script related to this?
eg: If someone is near by restaurant within 2 km, then he will get heading 2 as “reach us within 2 mins”.
Love this, thank you!
I’m not seeing the locations update in my campaign when I run the script – is that right? My locations in the campaign are still empty.
I keep getting the “Invalid argument: latitude. Should be of type: number (file Code.gs, line 22)”. What am I doing wrong?
Is there anything that can be set up for bid adjustments?
radius is currently misspelled in both instances (12/3/20)
thanks very much for sharing this script – will be trying it out.