Skip to main content

Google Tag Manager

Assemble Web can load a client-owned Google Tag Manager (GTM) web container after the active profile has been resolved as Adult. An unresolved profile and a Kids profile fail closed: neither state installs GTM or opens the data layer. Maintenance and startup-error documents do not install GTM.

Configuration

Set NEXT_PUBLIC_GTM_ID to a valid public web container ID such as GTM-ABC123. Deployment workflows map the public GitHub environment variable GTM_CONTAINER_ID into this build argument.

When the variable is absent or invalid, the integration installs nothing. A valid value makes the container available to the profile-aware measurement gate; it does not bypass that gate.

The integration intentionally omits GTM's noscript fallback. A static iframe would run before JavaScript can resolve the active profile and therefore cannot honour the Kids measurement boundary.

GitHub repository variables

  • Name: GTM_CONTAINER_ID
  • Value: a GTM web container ID, for example GTM-ABC123
  • Scope: repository or environment, with environment variables preferred when an environment needs an override

Profile transitions

The application creates a clean document boundary whenever measurement access changes:

  1. Adult to Kids or unresolved immediately blocks the existing data layer, clears provider identity and queues, removes commercial scripts, cookies and storage, and reloads the document.
  2. Kids to Adult reloads before installing GTM so a restricted document is never reused for Adult measurement.

Application-owned analytics emitters must check the same policy and must not queue events while the audience is unresolved or Kids.

Content Security Policy

The template permits the GTM loader from https://www.googletagmanager.com. Client applications must separately allow the network destinations required by every tag configured in their container. Those destinations are container-specific and must be confirmed in GTM Preview before deployment.

Ownership and validation

The application owns loading the configured container and exposing its data layer. The client remains responsible for the container's tags, triggers, variables, consent configuration, environments and publication lifecycle.

Before release, verify with browser network capture that a fresh unresolved or Kids session makes no request to GTM or its tag destinations, and that profile transitions do not leak queued or persisted commercial state across the hard reload boundary.