Adding STAT Reports to Google Sheets Using App Scripts

The creator’s views are totally his or her personal (excluding the unlikely occasion of hypnosis) and should not at all times replicate the views of Moz.

The staff at MacMillan Search has generated plenty of worth by combining automated STAT studies with Google Sheets. From including rating particulars to different software’s outputs, to giving the content material groups up-to-date “Individuals Additionally Ask” studies, the tip consequence has confirmed to be a fantastic time-saver in our week-to-week search engine marketing workflows by decreasing guide work and offering commonplace outputs that simply combine with any spreadsheet.

Why did we create this script?

STAT’s wealth of key phrase rankings particulars may be very helpful for enterprise SEOs to know each the macro and micro particulars of their rankings. Google Sheets is among the most typical cloud-based spreadsheets platforms, and is simple to share between groups and organizations. That’s why SEOs use each of those instruments recurrently when analyzing key phrase knowledge.

Regardless of this, documentation on the way to combine STAT into Google Sheets is proscribed. To deal with this hole, we created our personal script!

It’s confirmed helpful for a number of causes:

  1. Not everybody likes CSVs: We leverage the STAT studies to offer shoppers with route. Having to obtain a CSV and open it each week isn’t for everybody. With this script, you may set a weekly ticket with a hyperlink to the spreadsheet, and assessment the output recurrently.

  2. It saved us time: search engine marketing is a marathon, not a dash. After we establish a chance, there may be ongoing work that may have us reviewing studies recurrently. The weekly ticket method to assessment a spreadsheet shaves a while off of every job, and over the course of the engagement, this saved time provides up.

  3. Cleaner output: Utilizing Vlookups, Uniques, and so on., you may create a abstract web page of this info, highlighting what shoppers and/or readers care about. You may as well combine this info with different knowledge sources.

  4. Create automation with out utilizing an API: Automation, when performed appropriately, saves time. Utilizing this script with triggers opens the door to automation.

Easy methods to implement this script

1) Create a report in STAT

The STAT data base has a fantastic useful resource on studies. The one factor we might get particular on is the naming of the report and the recipient e mail.


What you identify your report will not be as necessary as protecting it clear and concise. This makes scaling to different tasks with related studies cleaner and simpler. Additionally, you will use this report identify as one of many variables within the scripts.

We additionally recommend inserting the corporate or undertaking identify on the finish of the report identify in parentheses (e.g. “(MacMillan Search)”). This makes it simpler to search out the report in your e mail.

Recipient e mail

It’s necessary to make use of a Gmail-enabled e mail for the account the place you’ll be constructing the sheet. This fashion, Google has a neater time getting the app script to extract the CSV from the e-mail.


For our shoppers, weekly knowledge is probably the most helpful — sufficient element to identify tendencies, however not a lot that it turns into simply noise to be ignored. For studies with restricted fluctuations (e.g. Individuals Additionally Ask), month-to-month may be passable.


Choose “Run this report instantly” to substantiate that your report works, proper after creating the script. This fashion, you’re able to set your triggers and let the information stream.

The remainder of the settings are particular to what particulars you need out of your report.

2) Create a Google Sheet and add the script

Create a brand new sheet in Google Drive underneath the account related together with your report’s recipient e mail. Then you definitely’re prepared so as to add the script:

1. Below the menu “Instruments”, choose “<> Script editor”.

2. Paste the script under into the “Script editor”.

3. Just a few issues will have to be edited to work together with your knowledge:

  • var COMPANY_NAME up to date to the corporate or undertaking identify you used whereas creating the STAT Report

  • var REPORT_NAME up to date to the identify of your report minus the corporate identify and parentheses

  • var SHEET_NAME up to date to the identify of the sheet within the spreadsheet

4. Affirm the Script works by saving it, refreshing the sheet, and when the menu “Handbook Replace” hundreds, choose “Import Key phrases”.

5. The primary time you run this you’ll get an “Authorization Required” pop-up:

Choose “Proceed”, comply with the steps, and choose “Import Key phrases” underneath the menu once more.

Your spreadsheet ought to now be populated with all the particulars out of your CSV.

3) Automate the inhabitants with triggers

Setting this sheet as much as routinely replace because the report comes out may be very straightforward utilizing Apps Script “Triggers”. To arrange the triggers:

1. Return into the “Script Editor”

2. Choose the “alarm” icon “Triggers”

    3. Choose “Add Set off”.

    4. Choose the operate “importKws”.

    5. Choose occasion supply “Time-driven”.

    6. Choose sort of time-based set off “Week Timer” for weekly studies, “Month Timer” for month-to-month studies, and so on.

    7. In our time zone, our studies normally come out late Sunday, so we choose early Monday morning:

    8. Click on “Save”

      The result’s a spreadsheet that recurrently updates, populated by an emailed STAT report.

      We’ve discovered many makes use of for this script — wherever we reference rank. And, since a undertaking may take time to get applied, we will present present rating info with out leveraging the API.

      We’re curious to learn the way you leverage it as nicely. For those who discover the script helpful, attain out to us on LinkedIn and tell us what you’re utilizing it for.

Latest news
Related news


Please enter your comment!
Please enter your name here