Skip to content

Analytics + Remarketing Layer

The measurement + remarketing foundation. Without consistent events and pixels, conversion work isn’t measurable and there’s no audience to remarket to. This layer gives every component one event funnel and gates ad/remarketing storage behind consent.

src/lib/analytics.ts · src/components/growth/ConsentBanner.tsx · tags in Layout.astro

import { track, trackLead, EVENTS } from '../lib/analytics';
track(EVENTS.ctaClicked, { location: 'hero' });
trackLead({ source: 'pricing_page' });

One call fans out to GA4 (gtag), GTM (dataLayer), and Meta Pixel (fbq) when each is present. SSR-safe (no-ops on the server).

ExportPurpose
track(event, props)Fire any event across all channels.
trackLead(props)The conversion signal — also emits GA4 generate_lead + Meta Lead for audiences/conversions.
EVENTSCanonical event-name constants — ctaClicked, formSubmitted, leadCaptured, leadPopupShown, draftRequested, pricingViewed, demoOpened.
TagLoads when
GA4 basealways (business.googleAnalyticsId)
Google Ads remarketingbusiness.googleAdsId is set
Meta Pixelbusiness.metaPixelId is set

Empty in brand.json = nothing loads. Set them to switch remarketing on per brand.

Analytics is on by default (AU-first); ad/remarketing storage (ad_storage, ad_user_data, ad_personalization) is denied until consent. The ConsentBanner (global, client:idle) flips them to granted on Accept and persists velocity.consent; once chosen it never re-shows.

Honest analytics-vs-ads split, a clear Accept/Decline banner, and no ad signals fire before consent — suitable for AU and defensible for EU/UK traffic.