The Google Analytics Data Export API exposes only baseline metrics for data feed queries, with a few exceptions. Typically, a baseline metric is a value that is stored as an aggregate in the Analytics servers, such as ga:visits or ga:adClicks. Calculated metrics, on the other hand, are commonly ratios or averages. These metrics are available in the Analytics report interface and in Custom Reporting. In those reports, there is a specific context provided by the report. Google Analytics determines the context of the report and performs the needed calculation for that report type.
Because a data query has no report context and can retrieve a variety of metric and dimension combinations, there is no way to determine the correct context for something like bounce rate or conversion rate. Instead, you can define the particular calculation you need, based on your objective. By restricting your calculation to a particular context, you ensure that they are meaningful to your objectives and consistent.
To craft your own calculated metrics, retrieve a combination of baseline
metrics and dimensions and make the calculation in your application. For example,
if you want to know the bounce rate for your website, you might query for both ga:bounces and ga:entrances,
and divide the number of bounces by the number of entrances to find the rate.
The following table describes a number of common calculations/queries by type,
and describes various ways to perform the calculation or query, depending upon
what you want to measure.
| Calculation Type | Objective | Method(s) | Notes |
|---|---|---|---|
| Bounce Rate | |||
| Bounce rate by browser or dimension other than page | ga:bounces/ga:entrances |
Use to calculate the total number of bounces for your entire site, or by a dimension other than ga:pagePath. This calculation divides the number of bounces (single request interactions of all types) by the number of sessions that included a pageview. When this is segmented by a dimension such as browser, you will receive the number of bounces by browser and entrances by browser. |
|
| Bounce rate for a particular page | ga:bounces/ga:uniquePageviews,ga:pagePath |
Use to calculate the bounce rate for a particular page. This calculation is mostly useful when queried with the ga:pagePath dimension to segment the results. This calculation asks for single-request visits (of all types) and divides that number by total unique pageviews across all visits. When filtered by a particular page URI, you will receive the bounce rate for that page. In this case, the query returns bounces that consisted of the filtered page divided by visits that included the filtered page. |
|
| Conversion Costs | |||
| For all transactions and goals | ga:adCost/(ga:goalCompletionsAll + ga:transactions) |
If you calculate revenue based on all goal completions, then this value should be part of your formula. | |
| For goals only | ga:adCost/ga:goalCompletionsAll |
If you are interested in calculating conversion costs based only on the values you specify for your goals, use this formula. | |
| For transactions only | ga:adCost/ga:transactions |
If your goal values do not add anything meaningful to your revenue, or if they are redundant values that are entirely captured in your revenue totals, use this formula. | |
| Exit Rate | You can use the following two formulas to calculate an exit rate. When examining exit rate for a page, it can be useful to use both formulas to determine the overall popularity of a page with respect to the page being the last in the session. Note: While it might seem logical to use |
||
| How many sessions ended on a particular page? | ga:exits/ga:uniquePageviews, ga:pagePath |
When segmented by ga:pagePath, returns the percentage of visits which included the page and also ended on the page. This calculation focuses on the number of sessions that included the page at least once and ended the session. |
|
| How many views of a particular page ended the visit? | ga:exits/ga:pageviews, ga:pagePath |
When segmented by ga:pagepath, returns the percentage views of the page (out of all the views) where the view ended the session. This calculation focuses on total pageviews for a particular page, so you can use this to determine frequent views of a page where that page was also the last in the session. |
|
| Goal Conversions | |||
| Total abandonments for a particular goal | ga:goal1Starts - ga:goal1Completions |
||
| Abandonment rate for a particulal goal | (ga:goal1Starts - ga:goal1Completions)/ga:goal1Starts |
||
| Conversion rate for a particular goal | ga:goal1Completions/ga:visits |
||
| Funnel completion rate for a particular goal | ga:goal1Completions/ga:goal1Starts |
Shown in the Abandoned Funnels report. | |
| Revenue | |||
| Average revenue per transaction | ga:transactionRevenue/ga:transactions |
||
| Average revenue per visit | ga:transactionRevenue/ga:visits |
||
| Average goal value per visit | ga:goalValueAll/ga:visits |
||
| Average revenue per advertisement click | (ga:transactionRevenue + ga:goalValueAll)/ ga:adClicks |
See the examples under conversion costs for other permutations you might use. | |
| Average event value | ga:eventValue/ga:totalEvents |
||
| Visitor Calculations | |||
| Average time on page | ga:timeOnPage/(ga:pageviews - ga:exits) |
This calculation removes the number of exits from the formula, so that the average does not account for those pages where an exit occurred. However, many web analysts prefer to include exits in the formula. | |
| Average session length | ga:timeOnSite/ga:visits |
||
| Percentage of new visits based on unique visits | ga:newVisits/ga:visitors |
||
| Percentage of new visits based on all visits | ga:newVisits/ga:visits |
||
| Navigation | |||
Given a page test.html, which pages are users coming from? |
dimensions=ga:previousPagePath
|
When you have a specific page in mind for which you want to find navigation, two queries are required. | |
Which pages are users going to after test.html? |
dimensions=ga:nextPagePath |