Skip to content

feat(packages/sui-segment-wrapper): remove manual ga4 implementation#1984

Merged
kikoruiz merged 5 commits into
masterfrom
remove-manual-ga4
May 12, 2026
Merged

feat(packages/sui-segment-wrapper): remove manual ga4 implementation#1984
kikoruiz merged 5 commits into
masterfrom
remove-manual-ga4

Conversation

@kikoruiz
Copy link
Copy Markdown
Member

@kikoruiz kikoruiz commented Apr 28, 2026

Summary

Add backwards-compatible GA4 integration with automatic mode detection and remove deprecated Adobe Analytics integration.

Changes

Backwards-Compatible GA4 Dual-Mode Integration

Added automatic mode detection to support both manual GA4 initialization (existing) and Segment GA4 destination (new):

LEGACY Mode (when googleAnalyticsMeasurementId is configured):

  • Manual GA4 initialization with gtag
  • Integration name: 'Google Analytics 4' with clientId and sessionId object
  • google_consents sent in context
  • analytics_storage included in context
  • All existing GA4 functionality preserved:
    • loadGoogleAnalytics(), getGoogleClientId(), getGoogleSessionId()
    • triggerGoogleAnalyticsInitEvent(), setGoogleUserId()
    • sendGoogleConsents() for GTM Consent Mode
    • Campaign tracking via getCampaignDetails()

NEW Mode (when googleAnalyticsMeasurementId is NOT configured):

  • Segment "Google Analytics 4 Web" destination handles all GA4 functionality
  • Integration name: 'Google Analytics 4 Web': true
  • google_consents sent in properties (Segment best practice)
  • No analytics_storage in context (handled by destination)
  • No manual gtag initialization or script loading
  • No "sui" init event (destination handles initialization)

Detection Logic:

  • Simple synchronous config check: !getConfig('googleAnalyticsMeasurementId')
  • Stateless detection on every call
  • New utility: src/utils/ga4Detection.js

Key Fixes:

  • integrations now sent in both main object AND context.integrations (fixed integration routing)
  • google_consents location optimized based on mode: context for LEGACY, properties for NEW
  • "sui" init event only fires in LEGACY mode

Adobe Analytics Removal

Removed deprecated Adobe Analytics integration (no longer used):

  • All Adobe Visitor API code removed
  • Backwards-compatible stubs provided:
    export const getAdobeVisitorData = () => Promise.resolve({trackingServer: '', version: ''})
    export const getAdobeMCVisitorID = () => Promise.resolve('')

BREAKING CHANGES:

ga4 web mode destinations needs to be used on segment
@kikoruiz kikoruiz added feature and removed feature labels May 11, 2026
@kikoruiz kikoruiz added feature and removed feature labels May 11, 2026
@kikoruiz kikoruiz added feature and removed feature labels May 12, 2026
@kikoruiz kikoruiz merged commit 18db57e into master May 12, 2026
2 checks passed
@kikoruiz kikoruiz deleted the remove-manual-ga4 branch May 12, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants