This document describes how you can construct Data Export API queries using a combination of dimensions and metrics. Not all combinations are valid, and when you request an invalid combination of dimensions and metrics, you will receive an error message indicating that you have made an invalid request. There are basically three ways you can determine if your request contains a valid combination:
The Analytics Data Export API provides a similar set of metrics and dimensions as the Custom Reporting interface of Google Analytics. All the combination restrictions that apply when creating a custom report also apply to constructing a dimension/metric query in the API. The easiest way for you to familiarize yourself with these combinations is to use the Custom Reporting section of Google Analytics and select the dimension(s) or metric(s) you most want to use for your query. Immediately after you select your dimension or metric in the interface, you will notice that some dimensions/metrics will be unavailable for you to add to the custom report.
All dimensions and metrics map logically over to the Data Export API dimensions and metrics, even though they may not have precisely the same name.
If you are interested in exploring which combinations are valid with a particular dimension or metric, refer to the tables below:
Important: This table illustrates only 2-field combinations, either for a metric/metric or a dimension/metric. Dimension-only queries are not valid. If you need to check the validity of a query that has more than 2 fields (e.g. dimension,dimenson,metric) use the query validation chart below, because multiple field combinations are more restrictive than 2-field combinations.
| Dimension Category | Valid Metrics |
|---|---|
| D1. Visitor, excluding Time dimensions | All metrics, except: M2. Campaign ga:visitors |
| D2. Campaign | All metrics, except ga:visitors |
D3. Content, excludingga:pagePath, ga:pageTitle |
All metrics, except: M2. Campaign M7. Events ga:visitorsga:visitsga:timeOnSite |
D3. Content, only forga:pagePath, ga:pageTitle |
All metrics, except: M2. Campaign ga:visitors |
| D4. Ecommerce | All metrics, except: M2. Campaign ga:visitors |
| D5. Internal Search | All metrics, except: M2. Campaign ga:visitors |
| Hour | All metrics, except: M2. Campaign ga:visitors |
Time dimensions, excluding ga:hour |
All metrics |
| D6. Navigation | M6. Goalsga:pageviewsga:transactionRevenuega:transactions |
| D7. Events | M1. Visitor, except |
| Metric Category | Valid Combinations |
|---|---|
M1. Visitor, only for ga:pageviews |
All dimensions |
| All metrics | |
M1. Visitor, only for ga:visitors |
Time dimensions, except ga:hour |
| M1. Visitor metrics | |
M1. Visitor, only for:ga:visits ga:timeOnSite |
All dimensions, except D6. Navigation, ga:exitPagePath, ga:landingPagePath, ga:secondPagepath |
| All metrics | |
M1. Visitor, excluding: |
All dimensions, except D6. Navigation |
| All metrics | |
| M2. Campaign |
D2. Campaign dimensions Time dimensions, except ga:hour |
All metrics, except M7. Events, ga:visitors |
|
M3. Content (ga:uniquePageviews) |
All dimensions, except D6. Navigation, D7.
Events |
All metrics, except ga:visitors |
|
M4. Ecommerce, only for: |
All dimensions |
All metrics, except ga:visitors |
|
M4. Ecommerce, excluding: |
All dimensions, except D6. Navigation |
All metrics, except ga:visitors |
|
| M5. Internal Search | All dimensions, except D6. Navigation, D7. Events |
All metrics, except ga:visitors |
|
| M6. Goals |
All dimensions, except D7. Events |
All metrics, except ga:visitors |
|
| M7. Events |
All dimensions, except D6. Navigation, ga:exitPagePath, ga:landingPagePath, ga:secondPagePath |
All metrics, except M2 Campaign, ga:visitors |
If your query contains more than 2 fields, use the chart below to determine allowable combinations for a group of dimensions and metrics. Keep in mind the following:
| If query contains... | Allowable combinations for multiple fields are: |
|---|---|
ga:visitor |
Dimensions
Time dimensions, except
ga:hourMetrics
M1. Visitor
|
| Any D6. Navigation |
Dimensions
Any D6. Navigation
Metrics
M6. Goals
ga:pageviewsga:transactionRevenuega:transactions |
| Any M2. Campaign —and/or— ga:adContent, ga:adSlot, ga:adSlotPosition |
Dimensions
D2.Campaign
Time dimensions, except ga:hourMetrics
Any metric except:
M7. Events ga:visitor |
| Only D3. Content (any from the group) |
Dimensions
D1.Visitor
D3.Content Metrics
Any metric except:
M2.Campaign M7. Events ga:visits ga:visitors ga:timeOnSite |
| Any D3. Content —and— D2. Campaign, except: ga:adContentga:adSlotga:adSlotPosition |
Dimensions
Any dimension, except:
D4. Ecommerce D6. Navigation D7. Events ga:adContentga:adSlotga:adSlotPosition Metrics
M1.Visitor except |
| Any D7. Event —and/or— ga:adContent, ga:adSlot, ga:adSlotPosition |
Dimensions
D1. Visitor
D2. Campaign D7. Events ga:pagePathga:pageTitle Metrics
M1.Visitor except
ga:visitorsD4. Ecommerce D7. Event |
| Anything other than listed above. |
Dimensions
Any dimension, except:
D3. Content D6. Navigation D7. Events ga:adContentga:adSlotga:adSlotPosition
Metrics
Any metric, except:
D2. Campaign ga:visitors |