Thursday, July 11, 2013

Metrics and dimensions in the AdSense and Ad Exchange Seller REST APIs


We have recently published several new resources to help developers build reporting calls to the API:

1. Metrics and dimensions reference pages, with each defined by the relevant values, formats and limits.
2. New metadata calls in the AdSense Management API V1.3 that allow developers to fetch the list of available dimensions and metrics, check compatibility between each other and find out what products are supported. A sample response might be:
{
  "kind": "adsense#reportingMetadataEntry",
  "id": "EXAMPLE_DIMENSION",
  "compatibleDimensions": [
    "1",
    "2",
    "4",
    ...
  ],
  "compatibleMetrics": [
    "AD_REQUESTS",
    "AD_REQUESTS_COVERAGE",
    "AD_REQUESTS_CTR",
    ...
  ],
  "supportedProducts": [
    "AFMC",
    "AFC",
    "AFV"
  ]
},
The compatibleDimensions field shows a list where each item is an integer representing a group of compatible dimensions. As there is no one-to-one relation between compatible dimensions, they are represented as groups (as shown below).

Examples
Group #1 Group #2 Group #3 Group #4
AD_CLIENT_ID
AD_FORMAT_CODE
AD_FORMAT_NAME





BID_TYPE_CODE
BID_TYPE_NAME







DATE
DOMAIN_NAME
MONTH
PLATFORM_TYPE_CODE
PLATFORM_TYPE_NAME
PRODUCT_CODE
PRODUCT_NAME
TARGETING_TYPE_CODE
TARGETING_TYPE_NAME
WEEK
AD_CLIENT_ID
AD_FORMAT_CODE
AD_FORMAT_NAME





BID_TYPE_CODE
BID_TYPE_NAME





BUYER_NETWORK_ID
BUYER_NETWORK_NAME
DATE

MONTH
PLATFORM_TYPE_CODE
PLATFORM_TYPE_NAME
PRODUCT_CODE
PRODUCT_NAME
TARGETING_TYPE_CODE
TARGETING_TYPE_NAME
WEEK
AD_CLIENT_ID
AD_FORMAT_CODE
AD_FORMAT_NAME
AD_UNIT_CODE
AD_UNIT_ID
AD_UNIT_NAME
AD_UNIT_SIZE_CODE
AD_UNIT_SIZE_NAME
BID_TYPE_CODE
BID_TYPE_NAME
COUNTRY_CODE
COUNTRY_NAME





DATE

MONTH
PLATFORM_TYPE_CODE
PLATFORM_TYPE_NAME
PRODUCT_CODE
PRODUCT_NAME
TARGETING_TYPE_CODE
TARGETING_TYPE_NAME
WEEK
AD_CLIENT_ID
AD_FORMAT_CODE
AD_FORMAT_NAME





BID_TYPE_CODE
BID_TYPE_NAME
COUNTRY_CODE
COUNTRY_NAME
CUSTOM_CHANNEL_CODE
CUSTOM_CHANNEL_ID
CUSTOM_CHANNEL_NAME


DATE

MONTH
PLATFORM_TYPE_CODE
PLATFORM_TYPE_NAME
PRODUCT_CODE
PRODUCT_NAME
TARGETING_TYPE_CODE
TARGETING_TYPE_NAME
WEEK

From the previous table, note that:
  • DATE, MONTH and WEEK are compatible with every group. 
  • DOMAIN_NAME (Group #1) is not compatible with CUSTOM_CHANNEL_* (Group #4). 
  • If you want to report on ad units (Group #3) you won’t be able to use custom channels since a custom channel can be applied to one or more ad units. 
  • Country names (Group #3) can be used in combination with ad units (Group #3) or custom channels (Group #4) but ad units cannot be combined with custom channels
Remember to visit the AdSense API forums or our Google+ page if you need any help generating reports!