Search code examples
phpadsenseadsense-api

Channel-wise Google adsense information


I am using adsense Management API and followed everything there to generate a demo report as it is described in the example on their site. The information I am currently fetching uses this information :

    $startDate = '2012-03-01';
    $endDate = '2012-04-18';
    $optParams = array(
      'filter' => array(
        'AD_CLIENT_ID==' . $adClientId
      ),
      'metric' => array(                    
        'CLICKS', 'PAGE_VIEWS','COST_PER_CLICK','EARNINGS'                  
      ),
      'dimension' => array('DATE'),
      'sort' => 'DATE'
    );

What I have to ask is is it possible to arrange this data according to the channels So that I get channel-wise information on EARNING, COST_PER_CLICK and PAGE_VIEWS. And how?


Solution

  • Assuming you're talking about custom channels, all you have to do is add one of the following to your list of dimensions, depending on what you prefer:

    • CUSTOM_CHANNEL_NAME
    • CUSTOM_CHANNEL_ID
    • CUSTOM_CHANNEL_CODE

    You can think of dimensions as groups, that is, what you're organising your data by.

    You can check this blog post for some more info.