The Keyword diagnostic script runs in Adwords for each of our clients and helps us to find out which keywords have issues with them, such as low search volume or bids below first page. Because the iterators in Google scripts have limits on how many things they can check we will be using the Adwords API which don’t have this limitation. For this script we will be using the keywords performance report API.
Firstly, we define the Google sheet we are using to output our results, so in the main function put
|var spreadsheet = SpreadsheetApp.openByUrl(‘SPREADSHEET_SHARE_LINK’);|
Secondly, we need to make the call to the API for the information the basic call for this is:
|var report = AdWordsApp.report(
“SELECT Criteria, FirstPageCpc, CpcBid, SystemServingStatus “ +
“FROM KEYWORDS_PERFORMANCE_REPORT “ +
“WHERE Status = ENABLED “ +
OK so just to explain the various parts in the API call above, in SELECT we put in the attributes and metrics to be pulled into the report. (To find more valid metrics look in the link above.) In this example we are getting criteria, which will give us keyword text to identify the keyword problems. We are getting the first page CPC and CPC bid. Lastly, we are getting system serving status which will show as eligible or low search volume.
In FROM we put the API we are using.
In WHERE we put conditions that we want our keyword to meet- in this case we are getting all the keywords that are enabled.
In DURING put the time period you want the data retrieval to be.
And finally we put in the API version we are using. As Google updates its API it will eventually stop supporting the use of older versions, and this field will need updating eventually which may require more changes to the call if they change the names of some metrics.
Now, split the report into rows with:
|var rows = report.rows();|
Lastly, take each row and put the variables in an array to send to the Google Sheet.
Now, we can set the script to run daily and get up-to-date information on keyword performance. FIlters can be set to show specific keyword issues, such as those with low search volume or bids below first page.