Google Sheets Scripts

Localize Your Keywords With This Google Sheets Script

Have you ever found yourself with a long list of keywords and a long list of locations and needed to combine the two? This super simple Google Sheets script does just that!

Script for Appending Location to Keywords

You can copy the script below and add it to your own Google Sheet (in Google Sheets, click on Extensions > Apps Script and then paste the code in). Or you can simply make a copy of this Google Sheet that already has it set up.

function LOCALIZE(kws, lcs) {
  const keywords = kws.map(keyword => keyword[0]).filter(keyword => keyword.length > 0);
  const locations = lcs.map(location => location[0]).filter(location => location.length > 0);
  const output = [];
  keywords.forEach(keyword => {
    locations.forEach(location => {
      output.push([`${keyword} ${location}`]);
    })
  });
  return output;
}

Want to automate Google Ads with custom scripts?

If you liked this script or would like a personalized one, we’re here to help! Our team of developers with experience in PPC can create custom scripts to automate any aspect of your Google Ads accounts. Schedule a discovery call to discuss how we can assist you in implementing automation scripts effectively.

How to Use the Localization Script

Once you’ve added this to your Google Sheet, using it is incredibly easy! From any cell in your Sheet, use it like you would any other formula: type =LOCALIZE( and add in two ranges. The first range refers to the keywords that need to have the location appended, and the second refers to the locations being appended. Every combination of both will be created and outputted into a cell.

So, for example, if I had all of my keywords in column B and all my locations in column C, my formula would be =LOCALIZE(B3:B, C3:C).

Recent Posts
Recent Posts