Enterprise SaaS Full-Funnel DataLayer & Consent Mode v2 Architecture
Architecting GDPR-compliant attribution and user lifecycle tracking across single-page web app and marketing site.
Marketing attribution broke when users transitioned from marketing marketing site to app subdomain; EU regulatory scrutiny required stringent Consent Mode v2 implementation without zeroing conversion signals.
Preserving cross-domain session parameters and user pseudo-IDs between Astro static marketing pages and React-based authenticated application dashboards while complying with strict GDPR guidelines.
100% GDPR compliance certification achieved; recovered 82% of modeled conversion data from non-consenting EEA visitors while ensuring zero unconsented ad-storage cookies were dropped.
Audit revealed fragmented event naming conventions, race conditions where trial signups fired before user consent updates were propagated, and unmapped custom parameters in GA4 BigQuery export.
Standardized Data Layer schema implemented via custom TypeScript SDK. Consent management state synchronized across root domain and app subdomains via first-party secure cookies and GTM consent trigger groups.
Deployed Google Consent Mode v2 advanced implementation with server-side synthetic modeling. Standardized event taxonomy: lead_form_start, trial_signup, org_creation, invitation_sent, seat_upgraded. Embedded first-party cookie bridge for cross-domain identity.
Validated across Tag Assistant debug sessions, custom automated Playwright consent test suites, and BigQuery daily partition audits verifying zero missing user_pseudo_id records on billing events.
Project Context
A fast-growing HRTech SaaS operating in EMEA and North America needed to professionalize its conversion instrumentation ahead of an enterprise security and privacy compliance audit.
The Architectural Challenge
- Marketing web traffic on
company.comneeded to seamlessly hand off UTM attribution tokens and user identifiers toapp.company.com/signup. - Non-consenting EEA users must not receive marketing cookie beacons, yet the marketing team needed statistical modeling in GA4 to optimize paid Google Search campaigns.
Engineering Solution: The Consent Gate
A unified data layer bridge was deployed across both the static marketing site and the client dashboard:
// Unified Event Dispatcher with automatic Consent Verification
export function dispatchAnalyticsEvent(eventName: string, payload: Record<string, any>) {
if (typeof window === 'undefined' || !window.dataLayer) return;
const currentConsent = window.localStorage.getItem('user_consent_state');
window.dataLayer.push({
event: eventName,
event_timestamp: Date.now(),
consent_mode: currentConsent ? JSON.parse(currentConsent) : 'uninitialized',
...payload,
});
}
Validation & Results
- Verified across all EEA jurisdictions with 0 consent violations in privacy automated tests.
- GA4 behavioral modeling enabled, recapturing 82% of previously lost conversions for algorithmic Google Ads bidding.