SCALIX help

← All tools

ga4_create_key_event

Google Analytics 4 write medium risk

Part of the Conversion Tracking Agent.

What it does

Mark an event as a key event (GA4's conversion) on a GA4 property (Analytics Admin API v1beta properties.keyEvents.create). event_name is the event as GA4 collects it (e.g. generate_lead); it need not have fired yet. counting_method ONCE_PER_EVENT (default) or ONCE_PER_SESSION; an optional default value with its currency is used when the event has no value parameter. The preview is refused when the event is already a key event. Needs the Marketer or Editor role on the property. Returns {applied, result: Google's KeyEvent}. 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 count an event (a form submit, generate_lead, a booking) as a conversion in GA4, e.g. after a tracking audit found the lead event is not a key event.

Inputs

NameTypeRequiredDescription
property_idstringyesGA4 property number (e.g. 123456789) or properties/123456789. From ga4_list_accounts_properties.
event_namestringyesLetters, digits and underscores, starting with a letter, at most 40 characters. Cannot be changed later.
counting_methodstringnoONCE_PER_EVENT (default: every event counts) or ONCE_PER_SESSION (at most once per session).
default_valuenumbernoValue used when the event carries none. Give it with default_currency_code.
default_currency_codestringnoISO 4217 code such as USD. Give it with default_value.
preview_idstringnoOmit 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.

Reminder

Confirm with the user which action this event records and that it should count as a conversion: a wrong key event inflates every conversion report and anything Google Ads imports from GA4.

Errors

Error classMeansWhat to doRetry
platform_unavailableGA4 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_reauthThe 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_deniedThe 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_argumentA 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_unknownGoogle 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
already_existsThe event is already a key event on the property; refused at preview.Nothing to do; ga4_list_key_events shows its settings.no

Edge cases

  • Google caps the number of custom key events per property; past the cap the commit fails with Google's message.
  • Key events count from the moment they are created; GA4 does not recount past data.