Repository navigation
Description
Problem
Phase 1 (#658) connects a Google Analytics account to the organization, and that's all it does. A connected account typically exposes many GA4 properties — one per site the customer runs — and nothing in the product says which of them is which brand. So today the connection is inert: we cannot pull a single number without first knowing that property X is the brand's site.
This is the GA equivalent of #642, which solved the same problem for Search Console.
Proposal
Mirror the Search Console mapping, adapting it to how GA4 identifies properties.
Storage. A per-brand column, e.g. brands.ga_property_id, alongside the existing brands.gsc_property. Nullable — a brand with no GA property simply contributes nothing, exactly like an unmapped GSC brand today.
Listing. Fetch the connected account's GA4 properties through the Composio Google Analytics toolkit. Note that manual tool execution requires a pinned toolkit version — Search Console needed COMPOSIO_GSC_TOOLKIT_VERSION for this reason, so expect a COMPOSIO_GA_TOOLKIT_VERSION counterpart with the same env-override treatment (composio.js).
UI. The mapping block under the Google Analytics card, reusing the shape of GscPropertyMapping in integrations-section.tsx — one row per brand, a property picker, and a "N of M brands mapped" counter.
The part that differs from Search Console — decide deliberately
GSC auto-mapping works because a property is a URL (https://www.example.com/), so matchGscProperty can compare it against the brand's domains. A GA4 property is a numeric id plus a display name, which may be anything the customer typed. So either:
- resolve each property's data streams and match the brand's domain against the stream's site URL (accurate, one extra call per property), or
- attempt a fuzzy match on the display name and otherwise leave it to the user (cheap, unreliable).
Whichever is chosen, manual selection must always be available and must win over any automatic guess. Document the choice in the PR.
Out of scope
- Pulling reports (sessions, AI-sourced traffic, conversions) and storing them — that is the next phase, mirroring GSC integration phase 2b: pull daily Search Console query stats for mapped brands #644.
- Any AI Traffic / Citations surface built on that data.
Acceptance criteria
- With Google Analytics connected, Settings → Integrations lists the account's GA4 properties and lets each brand be mapped to one (or none), persisted across reloads.
- Unmapped brands are unaffected, and orgs without the connection see no change.
- The mapping is org-scoped and role-gated the same way the GSC mapping is.
- Whatever automatic matching is implemented is overridable by hand.
Activity
feat(integrations): connect Google Analytics via Composio (#695)