Script to automatically exclude non-performing locations

Skip to first unread message

Liliana Ortiz

unread,
Oct 5, 2018, 9:30:31 AM10/5/18
to AdWords Scripts Forum
Hello guys,

Does any of you know of a script to automatically exclude non-performing locations at a city level if in the last 'X' days there are no conversions? Also to report the outcome on a Google Sheet : Locations excluded, Impressions, clicks, cost.

Many thanks in advance!

Lili

Dmytro Tonkikh

unread,
Oct 5, 2018, 9:39:42 AM10/5/18
to AdWords Scripts Forum
https://gist.github.com/tonkikh/1a86e80db3f166b277096bca6892f93e You need to translate comments from russian to english

Dmytro Tonkikh

unread,
Oct 5, 2018, 9:42:59 AM10/5/18
to AdWords Scripts Forum
Oh, sorry. Not that script!(


On Friday, 5 October 2018 16:30:31 UTC+3, Liliana Ortiz wrote:

Liliana Ortiz

unread,
Oct 5, 2018, 10:21:05 AM10/5/18
to AdWords Scripts Forum
Ouchs... yes I've seen placements somewhere in the script :( - I am still looking for it, if anybody is aware of such a script or can write it for me I would appreciate it. Thanks a mil!

Anthony Madrigal

unread,
Oct 5, 2018, 3:29:38 PM10/5/18
to AdWords Scripts Forum
Hi Liliana,

This automatic exclusion script could be a good place to start. You will need to modify it to suit your specific needs. For example, the query in getReportResults will need to retrieve entities with no conversions instead of low impressions. You can also modify the DURING clause use your preferred date range.

Please see this guide for examples on how to exclude locations. The part of the code that you need to edit to exclude locations is in main():
for (var i = 0; i < urls.length; i++) {
  videoCampaign
.videoTargeting().newPlacementBuilder()
   
.withUrl(urls[i])
   
.exclude();

However, instead of URLs you will be excluding location IDs. 

If you have any additional questions, please let us know.

Regards,
Anthony
AdWords Scripts Team

Liliana Ortiz

unread,
Oct 8, 2018, 6:44:58 AM10/8/18
to AdWords Scripts Forum
Thanks Anthony, I will try it and let you guys know if it works

Liliana Ortiz

unread,
Oct 8, 2018, 6:50:55 AM10/8/18
to AdWords Scripts Forum
Hello Anthony,

I have just double checked and the script you have shared is for video campaigns. Do you know if there is any script for "Search" campaigns to exclude Locations?
Thanks!

Anthony Madrigal

unread,
Oct 8, 2018, 2:41:50 PM10/8/18
to AdWords Scripts Forum
Hi Liliana,

This could be done by utilizing the geo performance report. You can extract city IDs from locations that meet the criteria you specified above by querying the geo performance report, storing the relevant IDs in an array, and then selecting the campaigns that you want to exclude the locations from. Note that to select search campaigns, you can use the standard campaign selector, AdWordsApp.campaigns().

You can also read exporting a report to a spreadsheet here

For example, the query could look like this:
 var cityIds = []; // The array that you will push all city IDs to
 
 
var report = AdWordsApp.report(
   
"SELECT CampaignName, CityCriteriaId, CountryCriteriaId, Impressions, Clicks, Cost " +
   
"FROM   GEO_PERFORMANCE_REPORT " +
   
"DURING LAST_30_DAYS");
 
var rows = report.rows();
 
 
while (rows.hasNext()) {
   
var row = rows.next();
   
var campaignName = row["CampaignName"];
   
var cityId = row["CityCriteriaId"];
   
var countryId = row["CountryCriteriaId"];    
   
var impressions = row["Impressions"];
   
var clicks = row["Clicks"];
   
var cost = row["Cost"];
   
    cityIds
.push(cityId); // Push the current city ID into a cityIds array
   
 
}

Then, you can select the campaigns that you want to exclude the location from. Here is a sample snippet for excluding locations from campaigns.

Regards,
Anthony
AdWords Scripts Team

Reply all
Reply to author
Forward
0 new messages