Documentation Index
Fetch the complete documentation index at: https://docs.linkutm.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Google Analytics integration links a linkutm workspace to a GA4 property over OAuth. Once connected, linkutm matches your short links against the property’s web data stream URLs and reports GA4 session metrics for each matched link. Endpoints live under/api/v1/google-analytics.
Connection flow
1. Start OAuth
1. Start OAuth
Call
GET /google-analytics/auth to get a Google consent URL and redirect the user to it.2. Callback
2. Callback
Google redirects the user back to
GET /google-analytics/callback. linkutm stores the OAuth tokens against the workspace and redirects the user to the app. The connection is not finished yet.3. Pick an account and property
3. Pick an account and property
Use
GET /google-analytics/metadata to list the user’s GA4 accounts, then again with accountId to list properties.4. Connect
4. Connect
Call
POST /google-analytics/connect with the chosen account and property. This sets the connection live.Check connection status
Query parameters
Workspace UUID.
Example
Response
GA4Connected is false and every selected_* field is null.
Get OAuth URL
state parameter.
Query parameters
Workspace UUID.
Example
Response
OAuth callback
Query parameters
Authorization code issued by Google.
The workspace UUID, round-tripped from the
auth step.Behavior
linkutm exchangescode for OAuth tokens and stores them against the workspace, then issues a 302 redirect to the app:
- Success:
{FRONTEND_URL}/{workspaceSlug}/ga4-events?event=success - Failure:
{FRONTEND_URL}/{workspaceSlug}/ga4-events?event=error
A successful callback only stores the OAuth tokens. The connection is not active until the user selects an account and property via
POST /google-analytics/connect.Connect a property
Body parameters
Workspace UUID.
GA4 account ID (the
code from metadata).GA4 account display name.
GA4 property ID (the
code from metadata).GA4 property display name.
Optional. OAuth access token, for manual connection without the OAuth callback flow.
Optional. OAuth refresh token, for manual connection.
Optional. OAuth scope string, for manual connection.
Example
Response
Disconnect
Query parameters
Workspace UUID.
Example
Response
List GA4 metadata
connect.
Query parameters
Workspace UUID.
When provided, returns properties for this account. When omitted, returns accounts.
Example
Response - accounts
Response - properties
code field is the identifier to pass as accountId or propertyId to connect.
Get matched links
Query parameters
Workspace UUID.
ISO 8601 date. Defaults to 30 days before
endDate.ISO 8601 date. Defaults to now.
1-indexed page number.
Page size.
Case-insensitive substring match on title, short code, or URL.
Example
Response
Response fields
| Field | Type | Notes |
|---|---|---|
data[].id, url, shortCode, title | mixed | Core link fields. |
data[].utmSource … utmContent | string | null | The link’s UTM values used to match GA4 sessions. |
data[].ga4Data | object | null | GA4 metrics for the link. null if the GA4 report request fails. |
ga4Data.views | integer | screenPageViews for matching sessions. |
ga4Data.clicks | integer | sessions count for matching sessions. |
ga4Data.conversions | integer | conversions for matching sessions. |
ga4Data.signUps | integer | sign_up event count. 0 in this endpoint (sign-up rows are not requested here). |
ga4Data.rate | string | Conversion rate, conversions / clicks as a percentage string. |
meta | object | Pagination: total, page, limit, totalPages. |
If the GA4 property has no web data streams,
data is empty and meta.total is 0.Get matched links totals
Query parameters
Workspace UUID.
ISO 8601 date. Defaults to 30 days before
endDate.ISO 8601 date. Defaults to now.
Example
Response
Response fields
| Field | Type | Notes |
|---|---|---|
totalViews | integer | Sum of screenPageViews across all matched links. |
totalClicks | integer | Sum of GA4 sessions across all matched links. |
totalConversions | integer | Sum of conversions across all matched links. |
totalSignUps | integer | Sum of sign_up event counts across all matched links. |
0 when the property has no web data streams or the GA4 report fails.
Get matched links combined
matched-links and matched-links/totals separately.
Query parameters
Workspace UUID.
ISO 8601 date. Defaults to 30 days before
endDate.ISO 8601 date. Defaults to now.
1-indexed page number.
Page size.
Case-insensitive substring match on title, short code, or URL.
Example
Response
Response fields
| Field | Type | Notes |
|---|---|---|
links.data | array | Page of matched links with ga4Data, same shape as matched-links. |
links.meta | object | Pagination: total, page, limit, totalPages. |
totals | object | Workspace-wide totalViews, totalClicks, totalConversions, totalSignUps. |
signUps value inside each links.data[].ga4Data is 0; sign-up counts are only aggregated into totals.totalSignUps.
Get link metrics
Query parameters
Workspace UUID.
Link UUID. Must belong to the workspace.
ISO 8601 date. Defaults to 30 days before
endDate.ISO 8601 date. Defaults to now.
Example
Response
Response fields
| Field | Type | Notes |
|---|---|---|
totalUsers | integer | GA4 totalUsers. |
sessions | integer | GA4 sessions. |
views | integer | GA4 screenPageViews. |
conversions | integer | GA4 conversions. |
bounceRate | number | Bounce rate as a percentage, 2 decimals. Normalized so a 0 to 1 ratio is multiplied by 100. |
averageSessionDurationSeconds | number | Average session duration in seconds, 2 decimals. |
If the link’s URL does not match any of the connected property’s data stream URLs, every field returns
0. The same all-zero response is returned if the GA4 report request fails.Get link unique users over time
totalUsers for a single link. Results are cached for 2 hours.
Query parameters
Workspace UUID.
Link UUID. Must belong to the workspace.
ISO 8601 date. Defaults to 30 days before
endDate.ISO 8601 date. Defaults to now.
Example
Response
Response fields
| Field | Type | Notes |
|---|---|---|
data | array | One { date, totalUsers } entry per day GA4 returned. date is YYYY-MM-DD. |
data is an empty array if the link does not match the property’s data streams, no GA4 property is selected, or the GA4 report fails.
Get link breakdown
Query parameters
Workspace UUID.
Link UUID. Must belong to the workspace.
Breakdown dimension. One of
browsers, devices, os, screen, countries, regions, cities, referrers, channels, events, age, gender, language.ISO 8601 date. Defaults to 7 days before
endDate.ISO 8601 date. Defaults to now.
Type to GA4 dimension
type | GA4 dimension |
|---|---|
browsers | browser |
devices | deviceCategory |
os | operatingSystem |
screen | screenResolution |
countries | country |
regions | region |
cities | city |
referrers | sessionSource |
channels | sessionDefaultChannelGroup |
events | eventName |
age | userAgeBracket |
gender | userGender |
language | language |
Example
Response
type=events, each item carries eventCount instead of sessions:
Response fields
| Field | Type | Notes |
|---|---|---|
data[].name | string | The dimension value (browser name, country, event name, etc.). |
data[].sessions | integer | Session count for the value. Present for every type except events. |
data[].eventCount | integer | Event count for the value. Present only when type=events. |
data is sorted by the metric descending. It is an empty array if the link does not match the property’s data streams, no property is selected, or the GA4 report fails.
Errors
| Code | When |
|---|---|
400 | GA4 not configured for the workspace, missing GA4 tokens, no GA4 property selected, failed Google authentication, or failed to fetch GA4 accounts, properties, or data streams |
401 | Missing or invalid JWT (all endpoints except callback) |
404 | Workspace not found, or link not found / not in the workspace |
429 | Rate limit exceeded (100 requests/minute per IP) |