Want to automatically add converting cities to your Google Ads location targeting? We’ve got a script for you.

In fact, we’ve been running this on our accounts since February 2019 and completely forgot to tell you about it.

With our Google Ads location targeting script, you’ll now be able to monitor which cities convert best for you and add appropriate bid adjustments to them too.

Wouldn’t it be cool if you could know exactly where your top converters are? Read on to find out how to make this a reality!

How to add the Google Ads script

If you’ve not run a script before, this one couldn’t be any easier. Google has got a handy page to show you how to set up your first script here:

https://developers.google.com/google-ads/scripts/docs/your-first-script

All you have to do is copy and paste our code below into the code editor instead of Google’s (boring) code.

Our Google Ads location targeting script

The Converting Location Adder

Here’s the code that you need to put into the editor.

/*******************************************************************************
*
* [CLA] Converting Location Adder
* Author: Luke Northbrooke & Nathan Ifill (@nathanifill), Impression
*
* This script adds all cities which have converted (at any point in the past) to
* campaigns to make it easier and quicker to add bid adjustments.
*
* v1.2
*
* Change History:
*
* v1.2
* - NI updated report duration to be all-time
* - NI updated targeting to only update enabled campaigns
*
* v1.1
* - LN changed targeting method to be cities instead of most specific
*
* Any suggestions? Email luke.northbrooke@impression.co.uk
*
*
*
*******************************************************************************/
function main() {
  var report = AdWordsApp.report(
    "SELECT CampaignName, CityCriteriaId, CountryCriteriaId"
    + " FROM GEO_PERFORMANCE_REPORT"
    + " WHERE Conversions > 0", {resolveGeoNames: false}
  );

  var rows = report.rows();

  while (rows.hasNext()) {

    var row = rows.next();
    var campaignName = row["CampaignName"];
    var cityId = row["CityCriteriaId"];

    var campaignIterator = AdsApp.campaigns()
        .withCondition('Name = "' + campaignName + '"')
        .withCondition('CampaignStatus = ENABLED')
        .get();

    if (campaignIterator.hasNext()) {
      var campaign = campaignIterator.next();
        try {
          if (cityId != 0) {campaign.addLocation(cityId);}
        } catch (e) {
          Logger.log("Error adding city with ID " + cityId);
        }
    }
  }

  Logger.log("I don't know who you are. I don't know what you want.")
  Logger.log("If you are looking for advertising budget, I can tell you I "+
  "don't have money.")
  Logger.log("But what I do have are a very particular set of skills, skills " +
  "I have acquired over a very long PPC career.")
  Logger.log("Skills that make me a nightmare for people like you.")
  Logger.log("If you convert now, that'll be the end of it. I will not look " +
  "for you, I will not pursue you.")
  Logger.log("But if you don't, I will look for you, I will find you, and I "+
  "will convert you.")
}

That’s it. There aren’t any options to change or tricky bits to catch you out. You just set it and forget it (which is exactly why we forgot to tell you about the script until now!).

You can run it once as one-off or schedule the script to run daily, weekly or monthly to keep your Google Ads location targeting constantly up to date.

You can keep your location targeting up to date with our handy script.

What does that say in the logs?!

When the script has finished running, it prints the following in the logs:

I don’t know who you are. I don’t know what you want. If you are looking for advertising budget, I can tell you I don’t have money. But what I do have are a very particular set of skills, skills I have acquired over a very long PPC career. Skills that make me a nightmare for people like you. If you convert now, that’ll be the end of it. I will not look for you, I will not pursue you. But if you don’t, I will look for you, I will find you, and I will convert you.

I mean, we could have just made it say “Script complete” but that’s just SO BORING.

(If you don’t get the reference, then you have missed out on one of the greatest films ever!)

Next steps

Once you’ve run the script, you’ll have tons of new cities on your campaigns.

Your Google Ads location targeting will be full of tons of new cities after running this script.

From here, it’s just a case of monitoring progress and changing the bid adjustments accordingly. When the cities are first added, they’ll all be set to 0%, so it’s down to you to go in and put what you feel would be appropriate given the performance.

Effective bid adjustments can take your Google Ads location targeting to the next level.

Need help? Just ask.

As part of our data-driven PPC strategies, we use scripts every day here at Impression. If you need help with getting this set up or want to know how scripts can help manage your account more efficiently, feel free to get in touch with us now.

Nathan Ifill

PPC Executive

PPC Account Executive at Impression. Putting the ‘ting’ into ‘digital marketing’. Follow Nathan on Twitter: @nathanifill

Leave a Reply

Your email address will not be published. Required fields are marked *