Sub topic 15
Going Further with Explorations and the Data API
Assume you know the GA4 interface, your property is collecting data, and you can view User acquisition and Traffic acquisition reports. This chapter shows how to investigate acquisition questions beyond the standard reports.
Explorations for flexible analysis
Standard reports answer common questions with fixed layouts. An Exploration lets you choose dimensions, metrics, filters, segments, and visualizations. Use one when you need to compare traffic sources in a way that the report does not support.
For example, suppose you want to compare session source and medium for users who completed a key event on mobile devices. In Explore, you could:
- Create a blank exploration.
- Add
Session source / mediumas a dimension. - Add
Sessions,Engaged sessions, andKey eventsas metrics. - Add a device-category filter for
mobile. - Add a segment for users who triggered the key event.
- Use a table or funnel to compare the results.
A dimension describes how data is grouped. A metric is a number calculated for each group. A segment is a reusable subset of users or sessions.
Explorations are useful for finding patterns, but remember that their scope still matters. A session source can change from one session to another. A first-user source describes how GA4 originally acquired the user.
The Data API for repeatable reports
The GA4 Data API returns report data to a program. It is useful when you need a scheduled spreadsheet, an internal dashboard, or a repeatable extract. The API does not create a new attribution model. It reads GA4 dimensions and metrics using the same property data.
This request groups the last 28 days by session-scoped channel and source/medium, then sorts the results by sessions:
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "yesterday" }],
"dimensions": [
{ "name": "sessionDefaultChannelGroup" },
{ "name": "sessionSourceMedium" }
],
"metrics": [
{ "name": "sessions" },
{ "name": "engagedSessions" },
{ "name": "keyEvents" }
],
"orderBys": [{ "metric": { "metricName": "sessions" }, "desc": true }],
"limit": 20
}The request body must be sent to the runReport method for a specific GA4 property. The calling identity also needs permission to access that property. Before automating a report, test the same dimensions and metrics in the GA4 interface. This catches invalid combinations and helps you confirm that the result answers the intended question.
| Need | Best starting point |
|---|---|
| Explore an unexpected traffic pattern | Explorations |
| Repeat the same query on a schedule | Data API |
| Compare several user or session subsets | Explorations |
| Provide data to another application | Data API |
A practical workflow
Use Explorations to investigate and refine a question. Record the dimensions, metrics, date range, filters, and scope that produced a useful view. Then reproduce that definition with the Data API if the result needs to run regularly.
Exercise
Which tool should you use first to discover whether mobile email sessions have a lower engagement rate than desktop email sessions?
Show answer
Use an Exploration first. Add device category and session source or medium, then compare sessions and engagement rate with a filter for email traffic.