Sayan J. Das
Sayan J. Das

Reputation: 922

Get the total earnings from a specific URL using the Adsense Management API

Is it possible to get the total all-time earnings of a specific URL (say, https://example.com/page/xyz) using the AdSense Management API? (preferably the PHP library).

If so, please post a code answer or atleast a concept of how it could be implemented.

BTW, the number of ad units or any specific ad units dont matter; I just want the total income from a specific URL on my site using the API

Upvotes: 2

Views: 1272

Answers (1)

Donovan McMurray
Donovan McMurray

Reputation: 199

You can use URL Channels to declare the specific pages you want to track, and then in the API you can include the URL_CHANNEL_ID or URL_CHANNEL_NAME dimension in your report to break down by URL.

Once your URL Channels are set up, you can check out the AdSense API example repository to see how to run a report. This repository has different folders for different PHP versions. Choose the folder corresponding to your version, then go to examples/GenerateReport.php for a starting point. The AdSense API docs have a full list of Dimensions and Metrics and the full report specification in case you want to make other changes.

Upvotes: 0

Related Questions