Associated Phrases Script
It’s one thing to know keywords, but the words associated with those keywords is taking it to the next level. When people search for jumpers, for example, do they focus on the colour of the jumper, or the brand, or the type of stitching? Use this script to find out!
How does the script work?
The script automatically analyzes account data to produce a report of all the phrases that are associated with your chosen terms. So, let’s say you choose “suitcase,” the report will show you all the fun ways people end up searching for that term, including all your favourite Google Ads metrics.
How do I use it?
To use the script, you need to make a blank Google spreadsheet (for the report) and make a note of its URL. Then copy the code below into a new script in your account, and change a few options at the top:
- startDate and endDate determine the date range of the data. Enter them in yyyy-mm-dd format.
- currencySymbol is used when formatting cost data in the report.
- campaignNameContains and campaignNameDoesNotContain filter which campaigns the script gets data from. For example, if campaignNameContains is [“Brand”, “Generic”] then only campaigns with names containing “brand” or “generic” are included. If campaignNameDoesNotContain is [“Display”, “Competitor”] then any campaigns with names containing “display” or “competitor” are ignored.
- This is not case-sensitive.
- Leave blank, , to include all campaigns.
- If you need to put a double quote into campaignNameContains or campaignNameDoesNotContain, put a backslash before it.
- ignorePausedCampaigns should be set to true if you only want to look at currently active campaigns, or false if you want to include them.
- Similarly ignorePausedAdGroups should be true to only look at currently active ad groups, and false to include paused ones.
- reportAdGroupLevel should be true if you want to report on phrases used in individual ad groups. If this is false, ad group level will not be reported.
- Campaign and account level data is always reported.
- spreadsheetUrl is the URL of a Google Doc spreadsheet, which the results will be written into. Create a blank spreadsheet and put the URL in here.
- textOfInterest is the list of competitor names, products, synonyms, or whatever else you’re interested in. The script will see what words and phrases also appear in searches that contain these pieces of text.
- These should be in double quotes and separated by commas, e.g. [“one”, “two”, “three”]
- This text will be compared against search queries. Don’t use punctuation that won’t appear in the search query report.
- Note that the script will only look at searches if the text appears in it as a whole phrase. For example, if your text of interest is [“go east”] it will look at searches like “go east now” but not “go easter eggs.”
- minNGramLength and maxNGramLength let you say what size of phrase to look for. For example, if you set minNGramLength to 2 and maxNGramLength to 4, the report will give the two word, three-word and four-word phrases that appear in search queries which also contain your chosen text.
- Set both to 1 to look at only single words.
- If clearSpreadsheet is true, any data already in the spreadsheet will be overwritten. If it’s false, then the script’s results will be added at the end of the sheets.
There are also some advanced options: Thresholds for the different statistics are given, so you can stop the report showing performance for phrases with very few searches.
If the script can’t write to the Google Sheet because it runs out of space, try using the thresholds to remove the less important phrases, or use reportAdGroupLevel to only report at campaign and account level.
If you’re having trouble with the script timing out, try running the script multiple times, using campaignNameContains or campaignNameDoesNotContain to look at different campaigns for each run. If you’re looking for phrases of different sizes, you could do separate runs for each size.
The Associated Phrases Script code