Some words, when you put them together, are awesome. Some are not. ‘Free bananas’ sounds good, ‘old bananas’ sounds bad. By appreciating words in the context of other words, we become better search query performance interpreters and human beings. Use this script to build your ad groups or create your negatives based on phrases rather than individual words.
Rather than just looking at individual words, it lets you split your queries into n-grams. An n-gram is a phrase made of n words: a 1-gram is a single word, a 2-gram is a phrase made of two words, and so on. For example, “this four word phrase” contains three 2-grams (“this four,” “four word,” “word phrase”) and two 3-grams (“this four-word” and “four word phrase”).
The script adds up the clicks, impressions, cost, converted clicks and conversion value of each query containing the n-grams — and calculates the click-through rate, cost per click, conversion rate, CPA and value/cost — so you can see their impact.
If the performance is good, you might want to make new ad groups around the n-gram; if the performance is bad, you might want to exclude the n-gram as a negative phrase-match keyword. The data is shown at ad group level, as well as campaign and account level, so you can look at whatever granularity you want.
Looking at longer phrases provides more insight, but it also means the phrase appears in fewer queries. So we’ve also included a “Query Count” column that shows how many queries each phrase appeared in. That means you can concentrate on commonly occurring phrases.
Lastly, there’s a word count analysis to tell you if longer or shorter queries work best for you.
At the top of the script, there are some options you will need to change, depending on your preferences and account setup:
If you find the script keeps timing out, it may be that your account is too big. Try running the script multiple times using campaignNameContains and campaignNameDoesNotContain to look at different campaigns each time. Set clearSpreadsheet to false so you don’t overwrite the data from previous runs. (If you want the account-level data, you can copy all of the n-grams from campaign level into a new worksheet and then use a SUMIF function to find the totals.)
To use the script, just copy and paste the following into your account: