Skip to content

feat(integrations): map each brand to a GA4 property - #703

Merged
gkhngyk merged 1 commit into
mainfrom
feature/694-ga-property-mapping
Aug 12, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/694-ga-property-mapping

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 1 (#658) connected a Google Analytics account to the organization and stopped there — a connected account exposes many GA4 properties, and nothing said which one belongs to which brand, so the connection did nothing.

This adds brands.ga_property_id and a mapping block under the Google Analytics card, mirroring the Search Console mapping from #642: one row per brand, a property picker, and a "N of M brands mapped" counter. Org-scoped and role-gated exactly like the GSC mapping.

The matching decision the issue asked us to make deliberately: data streams, not display names. A GA4 property is a numeric id plus whatever the customer typed as a name, so a name match would be a guess. Each property's web data streams carry the real site URL (webStreamData.defaultUri), which compares against the brand's domains the same way a Search Console property URL does. Listing is one call; streams are one call per property, so they run with bounded concurrency (8) and a configurable ceiling. Properties past the ceiling are still listed and still selectable by hand — they just sit out the auto-match. Manual selection always overrides.

Two things worth flagging for review:

  • Toolkit tools, not the proxy. LIST_ACCOUNT_SUMMARIES and LIST_DATA_STREAMS are used through tools.execute, the same path as Search Console, which means the same pinned-version requirement — hence COMPOSIO_GA_TOOLKIT_VERSION (default 20260721_00, matching the GSC pin).
  • The mapping UI is now shared. Rather than a second copy of GscPropertyMapping, both providers render one PropertyMapping component and supply their own loaders. The domain matching moved into property-match.ts; gsc.ts became a thin adapter for Search Console's "the property is the URL" shape, so its existing tests pass unchanged.

Migration 00050 has already been applied to the hosted database.

Related issue

Closes #694

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. With Google Analytics connected, open Settings → Integrations. A "Property mapping" block appears under the Analytics card once the properties load.
  2. A brand whose domain matches exactly one property's data-stream URL is premapped automatically; brands with no match stay "Not mapped".
  3. Pick a property by hand, reload — the choice persists. Set it back to "Not mapped", reload — it stays cleared.
  4. The picker shows the property's display name (and account), not the numeric id, both in the list and once selected.
  5. Search Console mapping still behaves exactly as before — same auto-match, same persistence.
  6. An org without the Analytics connection sees no change, and a self-host without COMPOSIO_GA_AUTH_CONFIG_ID still shows the "not configured" card.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@gkhngyk gkhngyk self-assigned this Aug 11, 2026
Phase 1 connected a Google Analytics account to the organization but left
it inert: a connected account exposes many GA4 properties and nothing said
which one belongs to which brand.

Adds brands.ga_property_id and a mapping block under the Analytics card,
mirroring the Search Console mapping.

Auto-matching resolves each property's web data streams and compares the
stream's site URL against the brand's domains, rather than guessing from
the display name. A GA4 property is a numeric id plus free text, so name
matching would be unreliable; the stream URL is the real site. Stream
lookups are one call per property, so they run with bounded concurrency
and a configurable ceiling — properties past it stay listed and manually
selectable, they just skip the auto-match. Manual selection always wins.

Both providers now render one shared PropertyMapping component instead of
a copy per provider; the domain matching moved to property-match.ts, with
gsc.ts adapting Search Console's "the property is the URL" shape to it.
@gkhngyk
gkhngyk force-pushed the feature/694-ga-property-mapping branch from 4943f25 to afd6460 Compare August 12, 2026 09:04
@gkhngyk
gkhngyk merged commit a60c099 into main Aug 12, 2026
4 checks passed
@gkhngyk gkhngyk mentioned this pull request Aug 24, 2026
7 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrations: map each brand to a GA4 property — Google Analytics Phase 2

1 participant