Get in touch with our team


How To Create Local Google Ads Dynamically

You can create super local Google Ads with a little bit of technical know-how, but hardly anyone actually does it. Want to stand out amongst your competitors? Follow our guide to create hyperlocal ads with our Location Data Updater.

Livin’ la vida local

Just to clarify, this guide is about how to create search ads that localise themselves based on the user’s location. That means, if someone is in Birmingham, they’ll see an ad containing the word “Birmingham”. However, if someone in Brighton saw the same ad, they’d see “Brighton” instead. Pretty cool, right?

Looking for local search ads?

If you’re looking for more information about Google local search ads, Google local inventory ads or any type of Google local business ads, check out the Impression blog for more information.

This guide will show you exactly how you can create dynamic ad copy that changes based on where the user is searching from so that your business can always appear local.

An example of the hyperlocal Google ads you'll be able to make after this guide

Impression don’t currently rent boats, but if we did, this might be how we’d attract our international customers via Google Ads.

Our Location Data Updater script

The script to help you set up your local Google ads actually contains instructions on how to set everything up, but we’ll repeat the steps later in this guide with screenshots to show you in greater detail.

Below is the script you’ll need. Before attempting to run it though, have a quick scan of the instructions below.

* [LDU] Location Data Updater
* Author: Nathan Ifill (@nathanifill), Impression
* This script adds cities which have had ad impressions to your business data
* so that you can implement these in your ad copy via ad customisers in order to
* make your copy appear hyperlocal to people searching in that particular city.
* v1.2
* Any suggestions? Email
* Change History:
* v1.1
* - NI added region where appropriate to stop ambiguity

function main() {
/*********************************** STEP 1 ***********************************/

// Copy the spreadsheet here to set up your own version:

// Once you have done this, paste the URL of your spreadsheet into the
// variable below.


// Don't change the names of the sheets in the spreadsheet or the script will
// stop working!

/*********************************** STEP 2 ***********************************/

// Run the script manually once.

/*********************************** STEP 3 ***********************************/

// Schedule the script to run daily.

/*********************************** STEP 4 ***********************************/

// After running this script for the first time, you'll need to import your
// location data.

// Download the "Location Data" sheet in your spreadsheet as a .csv file and
// upload this to your Business data in the Google Ads UI.

// To do this, go to Tools & Settings > Business data and add an ad customiser
// feed, making a note of the feed's name for the next step.

// Once you have done this, you should be able to set up a schedule to import
// the Location data automatically. Set this to update daily.

/*********************************** STEP 5 ***********************************/

// Add the ad customisers to your ad where you'd like the location to appear.

// For example, if you called your ad customiser feed "LocationData", you could
// put {=LocationData.Location} wherever you want your location to appear in
// your extended text ads.

// If you want to set a default location for your ads, you can add that in the
// ad customiser too. For example, if you called your ad customiser feed
// "LocationData" and wanted to use "UK" as your default location, you could
// write {=LocationData.Location:UK} in your ad. This would then show the
// location (e.g. "Nottingham"/"Portsmouth"/"Exeter") for everywhere that you
// have data for and "UK" for everywhere else.

/**************************** OPTIONAL BONUS STEP *****************************/

// Sit there and admire your handywork, casually pointing out your excellence
// to colleagues


  var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);
  var report ="SELECT Impressions, CityCriteriaId, " +
          "RegionCriteriaId, CountryCriteriaId FROM GEO_PERFORMANCE_REPORT " +
          "WHERE Impressions > 0 AND CityCriteriaId != 0 "
  var outputDataSheetName = "Output";
  var outputSheet = spreadsheet.setActiveSheet(spreadsheet.getSheetByName(outputDataSheetName));
  var locationDataSheetName = "Location Data";
  var locationSheet = spreadsheet.setActiveSheet(spreadsheet.getSheetByName(locationDataSheetName));
  var rows = report.rows();
  var locationArray = [];
  while (rows.hasNext()) {
    var row =;
    var city = row["CityCriteriaId"];
    var location = row["CityCriteriaId"] + ", " + row["CountryCriteriaId"];
    var region = row["RegionCriteriaId"];

    // region adding if defined
    if (region != "Unspecified" && region != city) {
      location = row["CityCriteriaId"] + ", " + region + ", "
                + row["CountryCriteriaId"];
      locationArray.push([city, location]);

  locationArray = locationArray.filter(onlyUnique).sort();
               .setValues([["Location (text)","Target location"]]);
  Logger.log("Data available at " + spreadsheetUrl);

function onlyUnique(value, index, self) {
  return self.indexOf(value) === index;

Dynamic, local Google Ads instructions

Simply follow the five steps below and you’ll have hyperlocal ads in no time.

STEP 1: Set up the spreadsheet

Our location data template

First things first, you’ll need to set up your spreadsheet.

We’ve already given you 39,893 cities to start you off, but you’ll soon be replacing these with some which are more appropriate for your business and the locations that it serves.

All you have to do is copy our template from here and then you can move on to Step 2.

STEP 2: Run the script for the first time

You should run the script manually once and then you can automate it from there.

Copy and paste the script above into your Google Ads account, making sure to change the bit where it says “PUT YOUR SPREADSHEET URL HERE IN THESE SPEECH MARKS” to the URL of your copy of our template – the spreadsheet you made by copying ours in Step 1.

Save the script with a name that you’ll remember. You’ll need to find it in the next step.

You might get asked to authorise the script. You’ll need to do this before you’ll be able to run it.

Access denied

In some cases, Google may ask you to do authorise the script several times, so if you find that you’re unable to run the script, that’s probably the reason. Look around for a yellow bar or a pop up asking you to authorise and then do it again.

Once the script is authorised, click Run in the bottom right corner of the script editor. If you’ve set it up correctly, the script will then run, clear all of the current locations in your spreadsheet and then repopulate it with any cities that your ads have ever been shown in.

Run is in the bottom right-hand corner of the script editor

Depending on the size of your account, the script could take anywhere between a few seconds and 30 minutes to run. You don’t have to sit there and watch it though: Since you clicked on Run, you’re free to carry on doing something else (even in the same window) and the script will keep doing its thing in the background.

Once the script has stopped running, you’ll need to open your spreadsheet of locations, go to the Location Data sheet and download the data as a .csv file.

Download your location data as a .csv file

It’s important that you’re on the Location Data sheet before you do this, as the .csv file will only download one sheet’s worth of data.

Once you’ve got your .csv file downloaded, save it somewhere memorable with a name that you won’t forget. We’ll need it for Step 4.

STEP 3: Schedule the script to run daily

If you want to keep your list of locations up to date, you should ideally run the script daily.

You can schedule this by going to Tools & Settings, then Scripts (under Bulk Actions).

From here, you need to find the script that you named earlier and under Frequency, click the pencil to Edit.

How to set the frequency of your local Google Ads script

From there, you’ll be given the option to select “Daily” and a time for the script to run each day. Choose a time when your prospects are likely to be asleep, like 03:00.

Set a daily frequency for the script

STEP 4: Set up your ad customiser feed

To set up your ad customiser feed, go to Tools & Settings in the toolbar and then Business Data under Setup.

Business data can be found under Setup in the main menu

Click the big blue plus (“+”) button to add a new feed and then select Ad Customiser data from the drop down menu.

Ad customiser data in the drop down menu

From here, you’ll be asked to upload the .csv file from Step 2.

You’ll have to choose a name for your data without spaces. This name is case-sensitive so choose wisely. For the sake of this tutorial, let’s assume that you went for “LocationData”.

Unfortunately, Google can’t yet match the location data for every tiny town on Earth and may throw up an error for the locations that it can’t find. In general though, about 95% of the locations you upload should be found and matched successfully.

Once your data has been uploaded, move on to the next step to find out how to reference the locations in your ads.

STEP 5: Insert the ad customisers into your ads

Now for the easy bit – actually putting the ad customisers into your extended text ads.

A mobile preview of what your local Google ads could look like

No, Impression don’t do boat rentals…yet.

If you called your location data “LocationData” in the previous step, then all you have to do is add {=LocationData.Location} wherever you’d like to see the town or city name in your ads. As you can see from the preview above, this code has been replaced with “Vienna” in the preview.

This ad would show “Nottingham” for people in Nottingham, “Birmingham” for people in Birmingham and “London” for people in London – all via the exact same ad.

It’s pretty cool, right?

If you named your location data something other than “LocationData”, however, you need to replace “LocationData” above with the name of your ad customiser feed. For example, if you called your feed “Cities”, you would add {=Cities.Location} to your ads instead.

Set default text in the ad customisers

It also possible to add default text too. If you want to show a default location, e.g. “UK”, when you don’t have the user’s location in your business data yet, add a colon and then the default text after “Location” in the ad customiser. For example, {=LocationData.Location:UK}. There’s no need for speech marks.

That means that if someone from a town or city that you haven’t previously advertised to triggers your ads, they’ll see “UK” in place of their location.

Let’s say you’ve added “UK” as your default text and one of the 1,841 people living in St. Davids in Wales searches for something related to your business, triggering your ad to show to them. If you don’t have St. Davids in your business data, your ad would show the default text “UK”. However, since you’ve scheduled the script above to run daily, “St. Davids” would be added to your business data within 24 hours. Following that, if that person or anyone else from St. Davids triggered one of your ads in the future, the ad would say “St. Davids” instead.

It can be much quicker to add the ad customisers en masse in Google Ads Editor, if you’re familiar with it. However, you won’t see the locations in the preview like you will when you add them via Google Ads’ online user interface.

Need help with your account?

Ideas like this are innovative but can be a bit tricky to set up. We do stuff like this all of the time so if you’re looking for someone to help you with your account, then feel free to get in touch.

As you can see from the above, when we say we use data-led innovation in our accounts, we mean it. Every day, our paid media team use a combination of technology and creativity to drive successful results for our clients all around the world.

If you’d like to find out if we could add value to your account, speak to our team today. We’d love to hear from you!