Core Reporting API - Common Queries

Here are several of the most common queries to the Core Reporting API. Note that the definitions only include dimensions, metrics, filters, and sort parameters— Anybody using these queries should fill in the date range, max results, and so forth.

General Queries

Users and Pageviews Over Time

This query returns the total users and pageviews for the specified time period. Note that this query doesn't require any dimensions.
metrics=ga:sessions,ga:pageviews
Try it now in the Query Explorer.

Mobile Traffic

This query returns some information about sessions which occurred from mobile devices. Note that "Mobile Traffic" is defined using the default segment ID -14.
dimensions=ga:mobileDeviceInfo,ga:source
metrics=ga:sessions,ga:pageviews,ga:sessionDuration
segment=gaid::-14
Try it now in the Query Explorer.

Revenue Generating Campaigns

This query returns campaign and site usage data for campaigns that led to more than one purchase through your site.
dimensions=ga:source,ga:medium
metrics=ga:sessions,ga:pageviews,ga:sessionDuration,ga:bounces
segment=dynamic::ga:transactions>1
Try it now in the Query Explorer.

Users

New vs Returning Sessions

This query returns the number of new sessions vs returning sessions.
dimensions=ga:userType
metrics=ga:sessions
Try it now in the Query Explorer.

Sessions by Country

This query returns a breakdown of your sessions by country, sorted by number of sessions.
dimensions=ga:country
metrics=ga:sessions
sort=-ga:sessions
Try it now in the Query Explorer.

Browser and Operating System

This query returns a breakdown of sessions by the Operating System, web browser, and browser version used.
dimensions=ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion
metrics=ga:sessions
Try it now in the Query Explorer.

Time on Site

This query returns the number of sessions and total time on site, which can be used to calculate average time on site.
metrics=ga:sessions,ga:sessionDuration
Try it now in the Query Explorer.

Traffic Sources

All Traffic Sources - Usage

This query returns the site usage data broken down by source and medium, sorted by sessions in descending order.
dimensions=ga:source,ga:medium
metrics=ga:sessions,ga:pageviews,ga:sessionDuration,ga:exits
sort=-ga:sessions
Try it now in the Query Explorer.

All Traffic Sources - Goals

This query returns data for the first and all goals defined, sorted by total goal completions in descending order.
dimensions=ga:source,ga:medium
metrics=ga:sessions,ga:goal1Starts,ga:goal1Completions,ga:goal1Value,ga:goalStartsAll,ga:goalCompletionsAll,ga:goalValueAll
sort=-ga:goalCompletionsAll
Try it now in the Query Explorer.

All Traffic Sources - E-Commerce

This query returns information on revenue generated through the site for the given time span, sorted by sessions in descending order.
dimensions=ga:source,ga:medium
metrics=ga:sessions,ga:transactionRevenue,ga:transactions,ga:uniquePurchases
sort=-ga:sessions
Try it now in the Query Explorer.

Referring Sites

This query returns a list of domains and how many sessions each referred to your site, sorted by pageviews in descending order.
dimensions=ga:source
metrics=ga:pageviews,ga:sessionDuration,ga:exits
filters=ga:medium==referral
sort=-ga:pageviews
Try it now in the Query Explorer.

Search Engines

This query returns site usage data for all traffic by search engine, sorted by pageviews in descending order.
dimensions=ga:source
metrics=ga:pageviews,ga:sessionDuration,ga:exits
filters=ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc
sort=-ga:pageviews
Try it now in the Query Explorer.

Search Engines - Organic Search

This query returns site usage data for organic traffic by search engine, sorted by pageviews in descending order.
dimensions=ga:source
metrics=ga:pageviews,ga:sessionDuration,ga:exits
filters=ga:medium==organic
sort=-ga:pageviews
Try it now in the Query Explorer.

Search Engines - Paid Search

This query returns site usage data for paid traffic by search engine, sorted by pageviews in descending order.
dimensions=ga:source
metrics=ga:pageviews,ga:sessionDuration,ga:exits
filters=ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc
sort=-ga:pageviews
Try it now in the Query Explorer.

Keywords

This query returns sessions broken down by search engine keywords used, sorted by sessions in descending order.
dimensions=ga:keyword
metrics=ga:sessions
sort=-ga:sessions
Try it now in the Query Explorer.

Content

Top Content

This query returns your most popular content, sorted by most pageviews.
dimensions=ga:pagePath
metrics=ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits
sort=-ga:pageviews
Try it now in the Query Explorer.

Top Landing Pages

This query returns your most popular landing pages, sorted by entrances in descending order.
dimensions=ga:landingPagePath
metrics=ga:entrances,ga:bounces
sort=-ga:entrances
Try it now in the Query Explorer.

Top Exit Pages

This query returns your most common exit pages, sorted by exits in descending order.
dimensions=ga:exitPagePath
metrics=ga:exits,ga:pageviews
sort=-ga:exits
Try it now in the Query Explorer.

Site Search - Search Terms

This query returns the number of sessions broken down by internal site search, sorted by number of unique searches for a keyword in descending order.
dimensions=ga:searchKeyword
metrics=ga:searchUniques
sort=-ga:searchUniques
Try it now in the Query Explorer.

Back to Top