Using Management API to Access My Own Account Information

123 views
Skip to first unread message

Alex S.

unread,
Jun 9, 2014, 2:54:21 PM6/9/14
to adsen...@googlegroups.com
I am creating a dashboard with information about my ads so I want to pull information from the performance reports from my own account (clicks, CTR, CPM, etc.). Is the Adsense Management API right for me? If not, what options do I have? 

galeksic

unread,
Jun 10, 2014, 7:14:51 AM6/10/14
to adsen...@googlegroups.com
I think it is exactly what you need for performance reports on dashboard.

service.accounts().reports().generate(
          accountId
="pub-0123456701234567",
          startDate
='today',
          endDate
='today',
          metric
=['EARNINGS','CLICKS', 'PAGE_VIEWS', 'COST_PER_CLICK', 'PAGE_VIEWS_RPM',
         
'PAGE_VIEWS_CTR'],
          dimension
=['AD_CLIENT_ID']).execute...

{
 
"startDate": "2014-06-10",
 
"kind": "adsense#report",
 
"rows": [
   
[
     
"ca-pub-0123456701234567",
     
"***",
     
"***",
     
"***",
     
"***",
     
"***",
     
"***"
   
],
   
[
     
"partner-pub-0123456701234567",
     
"***",
     
"***",
     
"***",
     
"***",
     
"***",
     
"***"
   
]
 
],
 
"endDate": "2014-06-10",
 
"totals": [
   
"",
   
"***",
   
"***",
   
"***",
   
"***",
   
"***",
   
"***"
 
],
...
}

On dashboard on your own [local]host.

Or integrated / extended with other Google services.

If you need only reporting (and you prefer / need SQL), BigQuery is another option.

(AdSense Host API is for AdSense host partners. https://developers.google.com/adsense/host/become-a-host)

Alex S.

unread,
Jun 10, 2014, 1:38:15 PM6/10/14
to adsen...@googlegroups.com
galeksic,

Thanks for those resources! Is there a way to access data from my own account and not clients through me? I don't want to have a redirect page because I just want to pull information from my own reports and I don't need any login from users, almost like a service account. 

Jose Alcérreca (AdSense API Team)

unread,
Jun 10, 2014, 1:50:15 PM6/10/14
to adsen...@googlegroups.com
Hi Alex,

Using OAuth2, the developer and the user are different entities. We don't support Service Accounts but you can use the API from an automatic/unmonitored script using refresh tokens and the "offline" access type. Every client library implements this in a different way. You can start here:


Cheers,
Jose
Reply all
Reply to author
Forward
0 new messages