Effective keyword optimization is crucial for any successful search campaign in Google Ads. One of the best methods to achieve this is through thorough search query analysis, which you should conduct regularly based on your campaign’s traffic volume. This guide introduces you to a powerful tool: the n-gram analysis using a Google Ads script.
What Are Google Ads Scripts?
Google Ads scripts are snippets of JavaScript code that automate tasks within your Google Ads account. They help you execute repetitive tasks efficiently, like pausing underperforming keywords or generating detailed reports. Using scripts can significantly streamline your workflow, especially for larger accounts.
Understanding N-Grams
N-grams are a unique way to analyze individual words within search queries. Instead of looking at the entire query as a single entity, n-grams break it down to understand how each word performs in your account. This granular analysis provides valuable insights into which keywords drive traffic and conversions.
Example
For instance, if you’re running a campaign for worker’s compensation insurance, you might see various search queries. Analyzing these queries using n-grams helps you discover which terms perform better and which ones are less effective.
Conducting an N-Gram Analysis in Google Ads
Running an n-gram analysis may sound daunting, but it’s straightforward. Follow these steps to get started:
- Copy the N-Gram Script: Visit the script page and copy the text.
- Access Google Ads Scripts: In your Google Ads account, navigate to the “Bulk Actions” section and click on “Scripts.”
- Add a New Script: Click the blue plus button to create a new script. Paste the copied text into the main function window.
- Create a Google Sheet: Go to Google Drive, create a new spreadsheet, and copy its URL.
- Link Your Spreadsheet: Return to the script manager, find the prompt for the spreadsheet URL, and paste in the URL of your new spreadsheet.
- Select Your Settings: Choose the date range for the search queries you want to analyze, and decide whether to include or exclude specific campaigns or ad groups.
- Determine the N-Gram Length: Set how many words you want to analyze. A setting of four words allows you to capture more complex search phrases.
- Authorize the Script: You’ll need to authorize the script to run.
Once the script is set up and executed, you’ll receive comprehensive n-gram data in your Google Sheet.
What to Expect from Your N-Gram Analysis
After running the script, your Google Sheet will have multiple tabs, each representing different n-gram levels. The report will include valuable statistics such as clicks, impressions, conversions, and cost per conversion.
Using N-Gram Reports
Utilize the data to filter for:
- High-cost terms with no conversions
- Queries with high impressions but low clicks
- Low-cost queries with high conversion values
This analysis empowers you to make informed decisions about your keyword and negative keyword lists.
Best Practices for N-Gram Scripts
- Manual Date Range: Remember that the date range is static; you’ll need to update it each time you run an analysis.
- Reset Filters: Always reset your filters after analyzing to ensure the data populates fully.
- Utilize Insights: Use the insights gained from the n-gram analysis to optimize your keyword strategies effectively.
Conclusion
N-gram analysis is a powerful method for optimizing your Google Ads campaigns. By leveraging this script, you can uncover insights that lead to better keyword performance, ultimately driving more conversions for your business.

