Your Guide to Google Analytics Request Composer

Google Analytics Request Composer

If you’ve ever worked with Google Analytics API, you are probably familiar with the Query Explorer. What many users don’t know about is that Google also has a similar tool called Request Composer.

The main difference between the two is that while Query Explorer is built on top of Reporting API v3 the Request Composer has v4 under the hood.

The v3 of Reporting API is still perfectly supported by Google but they recommend using v4 for all new developments, this is also what Google itself claims to be doing. They also have a very detailed guide for migrating from v3 to v4.

But before you start migrating, let’s use Google Analytics Request Composer to see what’s new in v4 (there are some pretty neat new features).

Here’s a quick overview of the new features in v4

  • Metric expressionsThe API allows you to request not only built-in metrics but also a combination of metrics expressed in mathematical operations. For example, you can use the expression ga:goal1completions/ga:sessions to request the goal completions per number of sessions.
  • Multiple date rangesThe API allows you in a single request to get data in two date ranges.
  • Cohorts and Lifetime valueThe API has a rich vocabulary to request Cohort and Lifetime value reports.
  • Multiple segmentsThe API enables you to get multiple segments in a single request.

Google Analytics Request Composer

Just like Query Explorer, Request Composer also lets you play around with Google Analytics Reporting API. Super useful whenever working with the API. If you haven’t tried Query Explorer yet, I recommend you check it out first. This way you can get a better overview of what each of the tools is good for.

So, now that you know that the Query Explorer lets you run queries against your Google Analytics account, including all the metrics and dimensions available in the GUI as well as the filters and segments, let’s see why they had to build another tool.

Histogram Request

One of the features the Reporting API v4 introduced is requesting histograms straight from the API. Let’s take a closer look.

Required input:

  • startDate
  • endDate
  • metrics
  • Histogram dimension
  • Buckets

Example input:

Histogram Query Sample Input
Histogram Query Example Input

Example output:

Histogram Query Example Output
Histogram Query Example Output

As you can see, with the Histogram Query you can define custom buckets. In our example, we divided 24 hours into 6 equal buckets. For more detailed information about the histogram buckets, take a look at this page.

Pivot Request

Another useful feature exclusively available in the Reporting API v4 is Pivot Request.

Required input:

  • startDate
  • endDate
  • metrics
  • dimensions
  • pivot metrics
  • pivot dimensions

Example input:

Pivot Query Example Input
Pivot Query Example Input

Example output:

Pivot Query Example Output
Pivot Query Example Output

Pivot Query in Reporting API v4 is a super useful feature and we managed to find a few good insights just by playing with it in the Request Composer. Go ahead, see what you can find from your data.

Cohort Request

A cohort is a group of users who share a common characteristic. For example, all users with the same Acquisition Date belong to the same cohort. The cohort analysis report lets you isolate and analyze cohort behavior.

While this feature is still in beta and you can only choose cohorts based on the acquisition date, some users already say it’s the single most useful feature of Google Analytics.

Required input:

  • startDate
  • endDate
  • cohort metrics
  • cohort size

Example input:

Cohort Query Example Input
Cohort Query Example Input

Example output:

Cohort Query Example Output
Cohort Query Example Output

While acquisition date based cohorts are useful, I personally can’t wait for this feature to allow creating cohorts based on other dimensions, such as device category and custom dimensions.

Metric Expression

A metric expression is a mathematical expression you define on existing metrics; it operates like a dynamic calculated metric. You can also define aliases to represent the metric expressions.

Required input:

  • startDate
  • endDate
  • metric expressions

Example input:

Metric Expression Example Input
Metric Expression Example Input

Example output:

Metric Expression Example Output
Metric Expression Example Output

Just like with other new features the v4 API introduced, making calculations with metrics was possible before but required some extra coding. Having the ability to do it on the query level makes things both faster and clearer.

Conclusion

While Google Analytics Reporting API v3 is still more popular than its successor, the new feature can really make a difference. I definitely recommend you explore what v4 has to offer and Request Composer is by far the best option for getting started.

Let us know in the comments below what are your thoughts on both v4 and Request Composer, should you have any questions just post them, too.

Google Analytics Request Composer

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign up for Reflective Data

5,000 sessions / month ×

Please enter your email

Submit

After submitting your email, we will send you the registration form.