Search Query Mining With Quality Score Script

If you run a grant account, low quality scores and low CTRs are a real pain. Anything below a QS of three or a CTR of 5% and you’re bust! This script is tailored for grant accounts needing a bit of extra help.

What’s included?

How does the script work?

This is a modified version of our n-gram performance script, with the goal of preventing grant accounts from being suspended with the inclusion of quality scores. 

It produces a search query report with impressions, average CTR, and calculates an average quality score of search queries containing the n-grams. You can then use filters on the spreadsheet, so it only displays results with CTR < 5% or an average QS < 3.

This will help inform you where strategic 1 or 2 word negatives, for example, could increase your CTR, by ensuring your ad won’t appear on searches with a low chance of getting a click. If you see instances of high performance, you might instead make new ad groups around the n-gram.

It can also help you identify common themes in keywords that give a consistently low-quality score, so you can deal with them more easily by improving ad copy or simply removing any underperforming terms from the account.

The report shows data at campaign-level as well as ad group-level. You’ll also get a word count analysis, showing what amount of words performs best. 

How do I use it?

Go to your account in the Google Ads interface, go to Bulk Actions, choose Scripts, then make a new script and paste in the code at the end of this article.

Then make a new Google spreadsheet, and copy and paste its URL in the code options (where it says ‘var spreadsheetUrl = “”).

You can also edit the following variables according to your needs:

  • startDate and endDate in the format of yyyy-mm-dd to set a date range for the script find data for
  • Set the currency used with currencySymbol
  • With campaignNameContains you can limit the script to only look at specific campaigns (e.g., campaign names containing “Generic”), or with campaignNameDoesNotContain you can exclude certain campaigns.
  • You can also ignore paused campaigns with ignorePausedCampaigns and ignore paused ad groups with ignorePausedAdGroups
  • Set checkNegatives to true if you want to remove search queries that would be excluded by your negative keywords
  • Use minNGramLength and maxNGramLength to set the length of phrases you’re interested in
  • If you set clearSpreadsheet to true, the script will overwrite current data in the spreadsheet. You set it to false, then the script’s results will be added on to the sheet’s tabs.

If you have any issues with the script timing out because your account is too big, try running it a few times using campaignNameContains and campaignNameDoesNotContain to look at different campaigns.

The Search Query Mining With Quality Score Script code