ga4_create_annotation
Google Analytics 4 write low risk
Part of the GA4 Analytics Agent.
What it does
Add an annotation to a GA4 property (Analytics Admin API v1alpha properties.reportingDataAnnotations.create): a dated note shown on GA4's charts, for one day (start_date only) or a range (start_date to end_date, inclusive, in the property's time zone), e.g. 'New landing page live' or 'Tracking fixed'. color PURPLE, BROWN, BLUE (default), GREEN, RED or CYAN (ORANGE is reserved for Google's own notes). title at most 60 characters, description at most 150. Returns {applied, result: Google's ReportingDataAnnotation}. ALPHA: annotations exist only in Google's v1alpha Admin API. Needs the analytics.edit permission on the Google connection; until Google has verified it for Scalix the tool answers platform_unavailable and changes nothing. Two-phase (ADR-028/029): the first call (no preview_id) checks the request against Google's published rules and returns a preview_id; nothing is changed. Google Analytics has no test mode, so Google checks the rest only when the change is applied. Re-call with that preview_id and identical arguments to apply it (single-use, 30 min; a changed, forged or replayed token fails closed). Every applied or unconfirmed change gets an audit row.
When to use it
Use when the user asks to record a change on GA4's timeline (a launch, a tracking fix, a site outage) so later reports explain the jump.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
property_id | string | yes | GA4 property number (e.g. 123456789) or properties/123456789. From ga4_list_accounts_properties. |
title | string | yes | 1-60 characters. |
start_date | string | yes | YYYY-MM-DD: the day, or the first day of a range. Past, present or future. |
end_date | string | no | YYYY-MM-DD, on or after start_date, for a range; leave it out for one day. |
color | string | no | PURPLE, BROWN, BLUE (default), GREEN, RED or CYAN. |
description | string | no | At most 150 characters. |
preview_id | string | no | Omit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview. |
Safeguards
A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.
Policy
A GA4 change alters what the client's property counts and labels from now on, in every report and in what Google Ads imports from it. Make it only on the authorizing client's own property, only as the exact preview the user approved in a later message, never in bulk or on a guess, and never to make numbers look better. Each change is logged. Scalix never deletes or archives GA4 settings. An annotation is visible to everyone with access to the property: keep it factual and free of personal data.
Reminder
Write the note the user approved, word for word; it is shown to everyone who opens the property.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
platform_unavailable | GA4 changes are not switched on in Scalix yet: Google has to approve Scalix's request to edit Analytics first. | Tell the user it is on Scalix's side; the message names where to make the change in Google Analytics meanwhile. | no |
needs_reauth | The Google connection was made without the permission to edit Google Analytics. | Reconnect Google in the Scalix dashboard and accept the permission to edit Google Analytics. | no |
permission_denied | The connected Google login lacks the role this change needs on the property. | Ask the property's admin to grant the role the message names (GA4 Admin -> Property access management), then preview again. | no |
invalid_argument | A field breaks Google's published rules (checked before any preview_id), or Google refused it at commit. | Fix the field the message names and call again for a new preview. | no |
outcome_unknown | Google Analytics timed out or answered 5xx after the change was sent, so it may have been applied. | Check the property first (the list tool for this change) and start over with a fresh preview only if it is not there. | no |
Edge cases
- Creating the same note twice makes two annotations; check ga4_list_annotations first when unsure.