Start a Project
Call Us  0161 505 1048

Development, Paid advertising, SEO

Google AdWords Report Automation Using AWQL

22 June 2016
Google AdWords Report Automation Using AWQL | Neon

As digital marketers, applying automation to daily or regular tasks frees up a lot of time, which can be better spent doing analysis and research.

This is especially the case when it comes to Google AdWords reporting, which can take up a lot of quality time if done entirely manually. This article will provide some guidance on how to automate Google AdWords reporting using AWQL. Let’s begin by talking about AdWords query language.

What is AdWords Query Language (AWQL)?

AdWords has a very simple SQL query-like engine to query reports. The reports created using AWQL can be scheduled to run automatically. The AWQL library is also available in many languages including PHP, .NET, Python, Java, Ruby etc. Using Google App scripts for automation purposes is beneficial, especially when using spreadsheets to automate reporting requirements.

The formal AWQL grammars are given for reference below.

Statement -> SelectClause FromClause1 WhereClause?
DuringClause2 OrderByClause? LimitClause?
SelectClause -> SELECT ColumnList
FromClause -> FROM SourceName
WhereClause -> WHERE ConditionList
DuringClause -> DURING DateRange
OrderByClause -> ORDER BY Ordering (, Ordering)*
LimitClause -> LIMIT StartIndex , PageSize

ConditionList -> Condition (AND Condition)*
Condition -> ColumnName Operator Value
Value -> ValueLiteral | String | ValueLiteralList | StringList
Ordering -> ColumnName (DESC | ASC)?
DateRange -> DateRangeLiteral | Date,Date
ColumnList -> ColumnName (, ColumnName)*
ColumnName -> Literal
SourceName -> Literal
StartIndex -> Non-negative integer
PageSize -> Non-negative integer

Operator -> = | != | > | >= | < | <= | IN | NOTIN | STARTSWITH | STARTSWITHIGNORECASE |
String -> StringSingleQ | StringDoubleQ
StringSingleQ -> ‘(char)’
StringDoubleQ -> “(char)”
StringList -> [ String (, String)* ]
ValueLiteral -> [a-zA-Z0-9.]*
ValueLiteralList -> [ ValueLiteral (, ValueLiteral)* ]3
Literal -> [a-zA-Z0-9
Date -> 8-digit integer: YYYYMMDD

The regular reporting task itself takes a lot of time when you are managing campaigns for multiple territories. Using the Google App script to automate the tasks in Google spreadsheets is convenient, because users can make template dashboards which will automatically update based on requirements.

adwords flowchart - diagram | Google AdWords Report Automation Using AWQL | Neon

How to automate AdWords using apps Script

The scripts can be created in the “Bulk Operations” section of the Google AdWords campaign being run as displayed in the screenshot below.

adwords screenshot 2 | Google AdWords Report Automation Using AWQL | Neon
adwords screenshot | Google AdWords Report Automation Using AWQL | Neon

The automate script can be scheduled to run based on user requirements

Scheduling can be done after creating the scripts, which can be scheduled to run hourly, daily, weekly, monthly etc.

The language used for automation is Google Apps script, which is JavaScript itself. If you are familiar with JavaScript, then the scripting is very simple. The functions used to access all platforms such as AdWords, Sheets, Docs should be trained.

The steps involved in accessing reports from AdWords using AWQL and writing it into Google spreadsheets is provided below. There is a procedure main () in the Google AdWords scripting, and the execution of script starts from that function.

Create a new Script in AdWords
API should be initialised with API version in the beginning.


apiVersion: ‘v201601’


As we are exporting the automated report to a Google spreadsheet, the full URL of the google spreadsheet should be linked with the automation script.
var SPREADSHEET_URL = ‘Your Google Spread Sheet URL’;

The AdWords time zone may be different than the spreadsheet, because it may have been stored in different servers and locations. In order to synchronise these time zones, execute the following statement. The spreadsheet is the object ‘SpreadsheetApp’.

To retrieve the report from AdWords, the function displayed below should be executed. The database from where the data is to be taken is available in the documentation here. The following report is executed from ‘ACCOUNTPERFORMANCEREPORT’.

‘SELECT Cost, Impressions, SearchImpressionShare, Clicks, Ctr, AverageCpc ‘ +


  'DURING '+ dateRange).rows().next();


In most reporting cases there should be a date range that you want to specify. The date range should be specified as ‘start date to end date’ in the format ‘YYYYMMDD,YYYYMMDD’. A simple procedure to find the date range for a previous month or an older month is given below. The parameter to be passed should be the index of the previous month. For example: if you pass variable ‘prevMonthIndex’ as ‘1’, then the full date range of the previous month is taken and ‘2’ is the month before last month and so forth. The same procedure could be applied for any number of previous months.
returnDateRange = function(prevMonthIndex){

var today = new Date();

today.setMonth(today.getMonth() – prevMonthIndex);

var noofDays = daysInMonth(today.getFullYear(), today.getMonth()+1);

var monthString;


monthString = '0'+(today.getMonth()+1).toString();


monthString = (today.getMonth()+1).toString();

return today.getFullYear().toString()+monthString+’01,’+today.getFullYear().toString()+monthString+noofDays.toString();


The full source code is available here.

Common use cases of AdWords scripts

As well as for reporting automation purposes, there are many other use cases for AdWords scripts. Some of the use cases are explained below.

Increase keyword bid when the quality score and CTR is high.

keyword screenshot | Google AdWords Report Automation Using AWQL | Neon

Create a historic quality score report in a spreadsheet.
Find out keywords that may be under-performing after optimisation.
Make your own business logic specific ROI metrics.
Alert when there is a sudden increase in searches due to some unforeseen conditions.


This article provides only an overview of how AWQL could be used to automate reporting tasks. But there are a number of other procedures in AdWords to improve the overall ROI of your campaign.

Related Items

Life Of The Search Party: What To Expect From Search In 2020

How to create landing pages that convert

The Key Trends Affecting Digital Advertising

We are here to help

Want to be at the top of the search ranks? How about a website that’ll give your audience a great experience? Or maybe you’re looking for a campaign that’ll drive more leads? Get in touch to find out how we can help.

Start a project
The design and dev team making notes | Start a project with Neon | Neon
Employee on telephone
Group work
Designer laughing
Computer typed on
Sausage dog
Writing on white board
Designer planning sitemap
Employee posting notes on board
Developer working
Group photo of CEO and Brand Ambassador
Employee in meeting
Employee in Meeting

Stay up to date

Privacy Policy

© Neon Digital Agency Ltd 2021. Part of

Inc & Co Logo