Working with Advanced APIs

The advanced services in AdWords scripts allow experienced developers to connect to certain public Google APIs with less set-up than using their HTTP interfaces. You use these APIs much like scripts’ built in services, and they offer the same conveniences like auto-completion and automatic authorization.

Possible uses for Advanced APIs

Google Analytics
You can use Google Analytics to track the traffic coming to your website and adjust your campaign bids accordingly. If you link a Google Analytics property to your AdWords account, you can also analyze customer activity on your website. This information can shed light on how much of your website traffic or sales comes from AdWords and help you improve your ads and website. You can learn more about linking Analytics and AdWords accounts on our help center.
Google BigQuery
You can load huge quantities of data into Google Cloud Storage, and then query that data using Google BigQuery. For example, you can load public weather data for the past 10 years and then query for a region's average temperature in a script that uses that information in adjusting bids. Another use would be to do number crunching over your account’s performance data over several years.
YouTube and YouTube Analytics
You can retrieve and update your videos, playlists, etc. as well as your videos' performance data to make bidding decisions.
Google Calendar
Your script can create events for future tasks (e.g., run a performance report for your campaigns 2 weeks from today), or perform actions based on an entry you created on your calendar (e.g., enable a campaign on a specific date).
Shopping Content
Your script can use the Google Content API for Shopping in Apps Script. This API gives Google Merchant Center users the ability to upload and manage their product listings and manage their Merchant Center accounts.
Google Tasks
Your script can create a reminder list for future tasks (e.g., run a performance report for your campaigns 2 weeks from today), or perform actions based on an entry you created in your reminder list. (e.g., enable a campaign on a specific date).
Google Prediction
You can use historical data to train the Google prediction engine and perform trend analysis. For example, if you are running a pharmacy and you have historical data on the day’s weather and cold medicine sales, then you can train a model using Google prediction engine and use that to forecast the sales for a given season. Similarly, if you sell thermal jackets, you can use historical weather data and your sales numbers to train a Google prediction engine model. Combine that with the weather forecast for a given day to predict sales for that date, and adjust your bids and budgets accordingly.
Google Slides
Your script can export campaign details and/or statistics to Google Slides to publish such information in a presentable format.

Enabling Advanced APIs

To see which Google APIs are available as advanced services, click the Advanced APIs button on the top editor bar.

This brings up the Advanced APIs dialog. Check the APIs you wish to enable.

Next, click the Google API Console link to bring up the API Console page in the Console, with the project associated with your script (note, if your project is not already selected, choose it from the Project drop-down list). Search for the APIs you wish to use in your script by entering the API name in the search bar.

In the search results, select the API, and on the following page choose Enable. Note, if you see a Disable button, then this API is already enabled. Repeat this action for each API you want to enable.

To view the list of enabled APIs for the project, select the Dashboard page. Verify that all the Advanced APIs you want to use for the script are listed.

Now close the Advanced APIs dialog to return to your editor. The new APIs will be enabled for your script and available in the autocomplete list.

What APIs are available?

As of now, the following APIs are available for use.
API Name Documentation
Google Analytics https://developers.google.com/apps-script/advanced/analytics
Google BigQuery https://developers.google.com/apps-script/advanced/bigquery
Google Calendar https://developers.google.com/apps-script/advanced/calendar
Google Fusion Tables https://developers.google.com/apps-script/advanced/fusion-tables
Google Prediction https://developers.google.com/apps-script/advanced/prediction
Google Slides https://developers.google.com/apps-script/advanced/slides
Google Tasks https://developers.google.com/apps-script/advanced/tasks
Shopping Content https://developers.google.com/apps-script/advanced/shopping-content
YouTube https://developers.google.com/apps-script/advanced/youtube
YouTube Analytics https://developers.google.com/apps-script/advanced/youtube-analytics

You can also refer to our code snippets page for some examples on how to use these APIs.

Final considerations

There are a few things to keep in mind when working with the Advanced APIs.

Project ID

Each AdWords script has a Google Cloud Platform Project ID (also known as a project number) associated with it. You can find your script’s project number by opening the Google API Console page from the Advanced APIs dialog. This project ID is created when you create the script, and is tied to the user who created the AdWords script. If the user who created the script is later removed from the account, then a user trying to access the script will be prompted to reauthorize the script and setup Advanced API dependencies again. A new Google Developer Project ID will also be created, and you will need to setup the Advanced APIs again, as explained earlier in this document.

Modifying Advanced APIs dependencies

Only the user who created the script in the account can change the Advanced APIs dependencies for that script.

Script permissions

When accessing the APIs, the script will use the permissions of the user who authorized the script. Ensure that the user who authorized the script has the required access to all Advanced APIs being used as well as the data the script needs. If you are using the Google Analytics API, ensure that the user who authorized the script has the necessary permissions for the Analytics account being accessed.

Terms and Conditions

Each of the Advanced APIs may have its own Terms and Conditions which you should accept when enabling the API in the Google API Console.

Quota

Most Advanced APIs have a free daily quota associated with it. Once your script exceeds this quota, the API will stop working until you request additional data, or the free quota is replenished. You can monitor the quota used by your script by opening the Google API Console for the script from the Advanced APIs dialog. The Google API Console also provides you a way to request additional quota for the API.

Billing

Some Advanced APIs may require you to pay for usage. These payments are managed through the Google Cloud Platform project associated with your script, and not through AdWords. See our documentation for more details on how to enable billing for your script’s Google Cloud Platform project.

Send feedback about...

AdWords Scripts
AdWords Scripts
Need help? Visit our support page.