Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add predefined reports to the curl examples repo #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions predefined_reports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Google Analytics Predefined Reports

## Overview

This folder contains examples of the Data API queries equivalent to [predefined
reports](https://support.google.com/analytics/answer/9212670)
available in the Google Analytics API. See the [predefined
ikuleshov marked this conversation as resolved.
Show resolved Hide resolved
reports guide](https://developers.google.com/analytics/devguides/reporting/data/v1/predefined-reports)
for a detailed description of each report.

## Run a query

### Using the API Explorer

To run a query in your browser, open the [API Explorer](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport?apix=true)
in your browser, populate the **property** field with your [property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id)
and copy the request body to the corresponding field in the API Explorer dialog, click **Execute**.
Comment on lines +15 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To run a query in your browser, open the [API Explorer](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport?apix=true)
in your browser, populate the **property** field with your [property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id)
and copy the request body to the corresponding field in the API Explorer dialog, click **Execute**.
To run a query in your browser, open the [API Explorer](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport?apix=true)
in your browser, populate the **property** field with your [property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id),
copy the request body to the corresponding field in the API Explorer dialog,
and click **Execute**.


### Using the command line

Follow instructions provided in the [Data API command line quickstart](https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-cli)
guide. When running the `curl` command, specify the filename containing the
predefined report you want to run, for example:

```
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
https://analyticsdata.googleapis.com/v1beta/properties/$GA_PROPERTY_ID:runReport -d @traffic-acquisition-session-primary-channel-group.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
https://analyticsdata.googleapis.com/v1beta/properties/$GA_PROPERTY_ID:runReport -d @traffic-acquisition-session-primary-channel-group.json
https://analyticsdata.googleapis.com/v1beta/properties/${GA_PROPERTY_ID}:runReport -d @traffic-acquisition-session-primary-channel-group.json

```

36 changes: 36 additions & 0 deletions predefined_reports/audiences.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "audienceName"
}
],
"metrics": [
{
"name": "activeUsers"
},
{
"name": "newUsers"
},
{
"name": "sessions"
},
{
"name": "screenPageViewsPerSession"
},
{
"name": "averageSessionDuration"
},
{
"name": "totalRevenue"
}
],
"metricAggregations": [
"TOTAL"
]
}
49 changes: 49 additions & 0 deletions predefined_reports/checkout-journey.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"funnelBreakdown": {
"breakdownDimension": {
"name": "deviceCategory"
}
},
"funnel": {
"steps": [
{
"name": "Begin checkout",
"filterExpression": {
"funnelEventFilter": {
"eventName": "begin_checkout"
}
}
},
{
"name": "Add shipping",
"filterExpression": {
"funnelEventFilter": {
"eventName": "add_shipping_info"
}
}
},
{
"name": "Add payment",
"filterExpression": {
"funnelEventFilter": {
"eventName": "add_payment_info"
}
}
},
{
"name": "Purchase",
"filterExpression": {
"funnelEventFilter": {
"eventName": "purchase"
}
}
}
]
}
}
47 changes: 47 additions & 0 deletions predefined_reports/demographic-details-country.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "country"
}
],
"metrics": [
{
"name": "activeUsers"
},
{
"name": "newUsers"
},
{
"name": "engagedSessions"
},
{
"name": "engagementRate"
},
{
"name": "engagedSessionsPerUser",
"expression": "engagedSessions/activeUsers"
},
{
"name": "averageEngagementTimePerUser",
"expression": "userEngagementDuration/activeUsers"
},
{
"name": "eventCount"
},
{
"name": "keyEvents"
},
{
"name": "totalRevenue"
}
],
"metricAggregations": [
"TOTAL"
]
}
30 changes: 30 additions & 0 deletions predefined_reports/ecommerce-purchases-item-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "itemName"
}
],
"metrics": [
{
"name": "itemsViewed"
},
{
"name": "itemsAddedToCart"
},
{
"name": "itemsPurchased"
},
{
"name": "itemRevenue"
}
],
"metricAggregations": [
"TOTAL"
]
}
42 changes: 42 additions & 0 deletions predefined_reports/event-count-by-event-name-over-time.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"pivots": [
{
"fieldNames": [
"date"
],
"orderBys": [
{
"dimension": {
"dimensionName": "date"
}
}
],
"limit": 28
},
{
"fieldNames": [
"eventName"
],
"limit": 5
}
],
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "date"
},
{
"name": "eventName"
}
],
"metrics": [
{
"name": "eventCount"
}
]
}
42 changes: 42 additions & 0 deletions predefined_reports/event-count-by-event-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"pivots": [
{
"fieldNames": [
"date"
],
"orderBys": [
{
"dimension": {
"dimensionName": "date"
}
}
],
"limit": 28
},
{
"fieldNames": [
"eventName"
],
"limit": 5
}
],
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "date"
},
{
"name": "eventName"
}
],
"metrics": [
{
"name": "eventCount"
}
]
}
30 changes: 30 additions & 0 deletions predefined_reports/events-event-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "eventName"
}
],
"metrics": [
{
"name": "eventCount"
},
{
"name": "totalUsers"
},
{
"name": "eventCountPerUser"
},
{
"name": "totalRevenue"
}
],
"metricAggregations": [
"TOTAL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "itemName"
}
],
"metrics": [
{
"name": "itemsViewed"
},
{
"name": "itemsAddedToCart"
}
]
}
42 changes: 42 additions & 0 deletions predefined_reports/items-viewed-by-item-name-over-time.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"pivots": [
{
"fieldNames": [
"date"
],
"orderBys": [
{
"dimension": {
"dimensionName": "date"
}
}
],
"limit": 28
},
{
"fieldNames": [
"itemName"
],
"limit": 5
}
],
"dateRanges": [
{
"startDate": "28daysAgo",
"endDate": "yesterday"
}
],
"dimensions": [
{
"name": "date"
},
{
"name": "itemName"
}
],
"metrics": [
{
"name": "itemsViewed"
}
]
}
Loading