SCALIX help

← All tools

ga4_check_compatibility

Google Analytics 4 read low risk

Part of the GA4 Analytics Agent.

What it does

Check which GA4 dimensions and metrics can be combined in a single report (properties.checkCompatibility) BEFORE running it, so report requests don't fail with INVALID_ARGUMENT/incompatibility at query time. Given a candidate set of dimensions and metrics (and optional filters), it returns per-field compatibility (COMPATIBLE / INCOMPATIBLE) for each dimension and metric, letting the agent prune the incompatible field and retry. Use compatibilityFilter=COMPATIBLE to return only fields that work together. This pairs with ga4_get_metadata (which lists valid names) — metadata answers 'does the field exist', checkCompatibility answers 'can these fields coexist in one report'. Honors the keyEvents-era naming (validate keyEvents, not the deprecated conversions alias). Read-only and cheap on quota.

Inputs

NameTypeRequiredDescription
property_idstringyesGA4 property numeric id; normalize to 'properties/{id}'.
dimensionsarray<string>noCandidate dimension API names to test together (max 9). Validate names via ga4_get_metadata first.
metricsarray<string>noCandidate metric API names to test together; prefer keyEvents over the deprecated conversions alias.
dimension_filterobjectnoOptional FilterExpression on dimensions; its fields are included in the compatibility evaluation.
metric_filterobjectnoOptional FilterExpression on metrics; included in the evaluation.
compatibility_filterstringnoCOMPATIBLE => return only fields compatible with the rest of the set; COMPATIBILITY_UNSPECIFIED => return all with their compatibility status.

Safeguards

Policy

Compatibility checks run under the analytics.readonly scope for the user's authorized property only (per-tenant isolation). Validate against keyEvents (the deprecated conversions alias should be mapped first) so the eventual report reconciles to the GA4 UI.

Reminder

This only inspects the user's own property schema compatibility — keep it tenant-scoped and don't leak one property's field set to another account.

Errors

Error classMeansWhat to doRetry
PROPERTY_NOT_FOUNDGA4 property {property_id} not found or inaccessible.Verify property id and access.no
PERMISSION_DENIEDConnected account lacks read access to property {property_id} (HTTP 403).Grant Viewer or re-authorize the analytics.readonly scope.no
TOKEN_REVOKEDAnalytics OAuth token invalid or revoked (HTTP 401).needs_reauth: prompt reconnect.no
INVALID_ARGUMENTGA4 rejected the compatibility check (HTTP 400): {surfaced message} — typically an unknown field name or >9 dimensions.Surface the GA4 message; fix/remove the unknown field (validate via ga4_get_metadata) and keep dimensions <=9. Do not guess names.no
RESOURCE_EXHAUSTEDGA4 Data API quota exhausted (HTTP 429).Back off 5s/10s/20s (cap 60s), retry once.yes
PLATFORM_UNAVAILABLEGA4 Data API transient server error (HTTP 500/503).Retry once with backoff; report if persistent.yes

Edge cases

  • All requested fields compatible: return success listing each as COMPATIBLE.
  • Some fields incompatible: return per-field status so the caller can drop the offending field and retry the report.
  • compatibility_filter=COMPATIBLE: response returns only the subset that coexists — use it to auto-prune.
  • Empty dimensions and empty metrics: nothing to evaluate — return a clear validation message.
  • Unknown field name: 400 (vs an incompatibility result) — distinguish 'does not exist' (use ga4_get_metadata) from 'exists but incompatible'.
  • Caller passes deprecated conversions/isConversionEvent — check keyEvents/isKeyEvent instead (Google accepts a deprecated name only while getMetadata lists it in deprecatedApiNames).
  • Custom dimension scope mismatches (event vs user) commonly drive incompatibility — surface that reason when available.
  • Expired token: refresh once and retry transparently.