2

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

Sayan J. Das
  • 852
  • 10
  • 19

1 Answers1

0

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.

  • 2
    But Adsense only allows me to create a maximum of 500 URL channels, which is way less than the number of pages I'll need to track since my site has mostly user-created content. My intention is to track the total earnings and pay a part of the revenue to the user who created the page, but URL channels would only allow upto 500. Is there any other way? Maybe using Analytics? – Sayan J. Das Jun 23 '20 at 03:19