Skip to content

Google Analytics

Query GA4 report data from inside an artifact via a workspace connector. ShareOut mints short-lived tokens server-side from your pasted service-account key — no ShareOut OAuth flow.

  1. In Google Cloud, create a service account with the Viewer role on your GA4 property (or add the service account email as a property user in GA4 Admin).
  2. Download the JSON key.
  3. In ShareOut → workspace Connectors, choose Google Analytics and paste the key plus your GA4 property ID.
  4. Use Test to verify before saving.

See Workspace connections for the REST API.

Reference the connector by name:

const sdk = await ShareOut.create();
const { data } = await sdk.connection('team_ga').fetch({
endpoint: 'reports.run',
body: {
dateRanges: [{ startDate: '28daysAgo', endDate: 'today' }],
dimensions: [{ name: 'date' }],
metrics: [{ name: 'activeUsers' }, { name: 'sessions' }],
},
params: { propertyId: '123456789' },
});

propertyId can be 123456789 or properties/123456789.

The provider calls the GA4 Data API (analyticsdata.googleapis.com/v1beta).

EndpointMethodDescription
reports.runPOSTRun a standard report
reports.batchRunPOSTRun multiple reports in one request
reports.realtimePOSTRun a realtime report (cached 30 s)
reports.pivotPOSTRun a pivot report
reports.funnelPOSTRun a funnel report
metadata.getGETAvailable dimensions and metrics for a property
MetricDescription
activeUsersUsers with engaged sessions
sessionsTotal sessions
screenPageViewsPage view count
bounceRateSingle-page session rate
averageSessionDurationAverage session length

600 requests/min, 10 requests/s, tracked per artifact. Quota is enforced by Google; a GA_ERROR_429 means the property’s daily token quota was reached.

CodeMeaning
GA_NOT_CONNECTEDConnector missing or credentials invalid
GA_ACCESS_DENIEDProperty not accessible with the service account
MISSING_PROPERTY_IDpropertyId was not supplied
GA_ERROR_429API quota exceeded