Integrations / Google Analytics
Google Analytics
Run reports on your Google Analytics 4 properties: traffic, events, conversions and realtime activity.
4 actions
OAuth 2
4 read0 write
Calls analyticsdata.googleapis.com
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "googleanalytics" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
| Scope | Why it is requested |
|---|---|
https://www.googleapis.com/auth/userinfo.email | See which Google account you connected |
https://www.googleapis.com/auth/analytics.readonly | See your Google Analytics reports and metadata |
Actions
Run several reportsreadgoogleanalytics.batch_run_reportsRun up to 5 Google Analytics 4 reports on one property in a single call. Each request has dimensions, metrics and dateRanges.
Needs scope: https://www.googleapis.com/auth/analytics.readonly
| Input | Type | Description | |
|---|---|---|---|
property_id | string | Required | Numeric GA4 property ID, e.g. 1234 |
requests | array of object | Required | Up to 5 RunReportRequest objects (dimensions, metrics, dateRanges, ...) |
await setu.execute({
userId: "user_1",
action: "googleanalytics.batch_run_reports",
input: {
"property_id": "<property_id>",
"requests": []
},
});Get dimensions and metricsreadgoogleanalytics.get_metadataList the dimensions and metrics available for a property (including custom ones), so a report can be built with valid names.
Needs scope: https://www.googleapis.com/auth/analytics.readonly
| Input | Type | Description | |
|---|---|---|---|
property_id | string | Required | Numeric GA4 property ID, e.g. 1234 (use 0 for the standard set common to all properties) |
await setu.execute({
userId: "user_1",
action: "googleanalytics.get_metadata",
input: {
"property_id": "<property_id>"
},
});Run realtime reportreadgoogleanalytics.run_realtime_reportRun a realtime Google Analytics 4 report (activity in the last 30 minutes by default), for example active users by country right now.
Needs scope: https://www.googleapis.com/auth/analytics.readonly
| Input | Type | Description | |
|---|---|---|---|
property_id | string | Required | Numeric GA4 property ID, e.g. 1234 |
dimensions | array of object | Optional | Dimensions, e.g. [{"name":"country"}] |
metrics | array of object | Required | Metrics, e.g. [{"name":"activeUsers"}] |
minute_ranges | array of object | Optional | Optional, up to 2, e.g. [{"startMinutesAgo":29,"endMinutesAgo":0}] |
limit | integer | Optional | Max rows |
await setu.execute({
userId: "user_1",
action: "googleanalytics.run_realtime_report",
input: {
"property_id": "<property_id>",
"metrics": []
},
});Run reportreadgoogleanalytics.run_reportRun a Google Analytics 4 report for a property: choose dimensions, metrics and date ranges (for example sessions by country over the last 28 days).
Needs scope: https://www.googleapis.com/auth/analytics.readonly
| Input | Type | Description | |
|---|---|---|---|
property_id | string | Required | Numeric GA4 property ID, e.g. 1234 (Admin > Property settings) |
dimensions | array of object | Optional | Dimensions, e.g. [{"name":"country"}] |
metrics | array of object | Required | Metrics, e.g. [{"name":"activeUsers"}] |
date_ranges | array of object | Required | e.g. [{"startDate":"28daysAgo","endDate":"today"}] |
dimension_filter | object | Optional | Optional FilterExpression on dimensions |
order_bys | array of object | Optional | Optional sort order |
limit | integer | Optional | Max rows (default 10000) |
offset | integer | Optional | Rows to skip |
await setu.execute({
userId: "user_1",
action: "googleanalytics.run_report",
input: {
"property_id": "<property_id>",
"metrics": [],
"date_ranges": []
},
});