The AdSense service allows you to use the AdSense Management API in Apps Script. This API gives AdSense customers the ability to get information about the structure of their account and run reports on how it is performing.
Reference
For detailed information on this service, see the reference documentation for the AdSense Management API. Like all advanced services in Apps Script, the AdSense service uses the same objects, methods, and parameters as the public API. For more information, see How method signatures are determined.
To report issues and find other support, please ask on Stack Overflow using the adsense-api tag.
Sample code
The sample code below uses version 2 of the API.
List accounts
This sample lists all of the accounts available to the user. The accounts are
specified as resource names, for example, accounts/pub-12345
, that can be used
in other methods, such as listing ad clients. Notice the use
of page tokens to access the full list of results.
List ad clients
This sample lists all of the ad clients for a given account. Specify the account
as a resource name, for example, accounts/pub-12345
. You can get the account
resource name by using the List accounts sample code.
List ad units
This sample lists all of the ad units for a given ad client. Specify the ad
client as a resource name, such as accounts/pub-12345/adclients/ca-pub-12345
.
You can get the ad client resource name by using the
List ad clients sample code.
Generate a report
This sample generates a report over your AdSense account and outputs the results to a spreadsheet.