The @laioutr-app/gtm package integrates Google Tag Manager (GTM) into a Laioutr-powered Nuxt app. It does not register any orchestr handlers; instead it (1) injects the GTM script and noscript iframe into the app head, (2) adds a client plugin that initialises the data layer, sets Google Consent Mode v2 defaults and updates them from the Laioutr consent store, and (3) registers a tracking adapter with the Laioutr tracking store (from @laioutr-core/frontend-core) so events pushed to the tracking store are forwarded to the GTM data layer.
Configuration is minimal: containerId (GTM container ID, e.g. GTM-XXXXXX) is required; layer (data layer variable name) is optional and defaults to dataLayer. Both options are in public runtime config. The module installs @laioutr-core/frontend-core on prepare so the consent and tracking stores are available.
The module expects configuration under the key @laioutr-app/gtm in nuxt.config.ts (or via runtimeConfig). One option is required; one has a default.
| Option | Type | Description |
|---|---|---|
containerId | string | Google Tag Manager container ID (e.g. GTM-XXXXXX). Used in the script URL https://www.googletagmanager.com/gtm.js?id={containerId}&l={layer} and in the noscript iframe. Find it in your GTM container settings. |
layer | string | Name of the data layer variable on window. Default: dataLayer. If you use a custom data layer name in GTM, set it here so the script and plugin use the same variable. |
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@laioutr-app/gtm'],
'@laioutr-app/gtm': {
containerId: process.env.GTM_CONTAINER_ID!,
layer: 'dataLayer',
},
});
Use an environment variable for containerId in production if you prefer not to hardcode it; the value is public so it can be exposed to the client.
src pointing to https://www.googletagmanager.com/gtm.js?id={containerId}&l={layer} (async). (2) A noscript tag containing the GTM iframe (https://www.googletagmanager.com/ns.html?id={containerId}) for users with JavaScript disabled.window[layer] exists (e.g. window.dataLayer = window.dataLayer || []). (2) Pushes { 'gtm.start': timestamp, event: 'gtm.js' } to the data layer so GTM loads. (3) Sets Google Consent Mode v2 default state via gtag('consent', 'default', { ... }): ad_storage, analytics_storage, functionality_storage, personalization_storage are denied; security_storage is granted; wait_for_update is 500. (4) Subscribes to useConsentStore().activeAdapter consent changes: when statistics is granted, it pushes consent update with analytics_storage and functionality_storage granted; when marketing is granted, it pushes ad_storage and personalization_storage granted. (5) Registers a tracking adapter with useTrackingStore(): the adapter’s track(event) pushes { event: event.eventName, ...event.payload } to the data layer. Other parts of your app (or other apps) can use the tracking store to send events; GTM receives them and can fire tags accordingly.This package does not provide orchestr queries, actions, links, or resolvers. It adds GTM to the page and connects it to the Laioutr consent and tracking stores.
consent update so Google tags (e.g. GA4, Ads) can respect consent.event and the event payload. Use GTM triggers to react to these event names and payloads.GTM-XXXXXX). Configure your tags (e.g. GA4, conversion tracking) and triggers in the GTM UI.This package does not set or read cookies itself. GTM and the tags you configure in it (e.g. GA4) may set their own cookies; consent updates pushed by this package help those tags respect user consent when using Consent Mode.
@laioutr-app/gtm (e.g. from env).Cookiebot
Developer documentation for the Laioutr Cookiebot app package. Add Cookiebot cookie consent management to your Nuxt app via the Laioutr consent store.
Nimstrata Google Retail API
Developer documentation for the Laioutr Nimstrata app package. Add AI-powered search, recommendations, suggested search, and event tracking to your Laioutr frontend via the Nimstrata (Retail Connect) API, with Shopify integration.