What I need to do:
I want to generate adsense reports programmatically to get the earnings and the page views for each ad in my website that lets users post their own articles, so I need to know from which URL the earning comes from to be able to share the revenue with the users, and show them their statistics.
What I tried:
I went to the API, and found reports.generate, which seems to do what I want, so I tried it in their "API Explorer" to see what kind of data was available, and in the Metrics and Dimensions page, I found these parameters that seemed to do what I wanted:
Dimensions: DATE, URL_CHANNEL_NAME
Metrics: EARNINGS, PAGE_VIEWS
EARNINGS, PAGE_VIEWS, and DATE work as expected, but URL_CHANNEL_NAME only gives me the base URL of the website, not the URL of the page in which the ad is shown that I would need.
For example, if my website is https://stackoverflow.com
and I show ads on https://stackoverflow.com/posts/somePostUniqueID
I'd like to see the latter in the reports, but I only see https://stackoverflow.com
.
So, instead of URL_CHANNEL_NAME
I also tried:
URL_CHANNEL_ID
: Same as URL_CHANNEL_NAME
, but with the accountId
prepended to it, which I don't need, since it's the same for every URL.
DOMAIN_NAME
: Also just gives the base domain, without the specific URL
CUSTOM_CHANNEL_NAME
: Seems that I can only add these manually, and they're limited to 50, so probably not what I want in this case.
And the rest of them don't seem to be relevant to my problem.
The posts on my site are generated dynamically from the URL, so I'm worried that the ad is not able to read the URL properly to send it back to the reports, could this be the case?
The website is made with Angular 5, and when clicking a link formatted like this:
sitename.com/posts/uniquePostURL
The uniquePostURL
is parsed, and the matching article is loaded, so it takes a while for the content to load, and the base page in which the ad is is actually just sitename.com/posts
, and since in the reports I see both sitename.com
and sitename.com/posts
when using URL_CHANNEL_NAME
, I'm worried that might be the reason.
Any idea if that is actually the reason, or if that's fine and I'm doing something else wrong?
Thank you.