npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackonward/google-tag-manager-nuxt

v0.3.3

Published

Consent-aware Google Tag Manager transport and analytics composition module for Nuxt

Readme

@stackonward/google-tag-manager-nuxt

Consent-aware Google Tag Manager composition for Nuxt. The module installs the provider-neutral analytics runtime, loads GTM through @nuxt/scripts, and registers the Google transport only in the browser.

Install

pnpm add @stackonward/google-tag-manager-nuxt @nuxt/scripts

Nuxt and Vue are peer dependencies. See Compatibility for the supported ranges.

Setup

export default defineNuxtConfig({
  modules: ["@stackonward/google-tag-manager-nuxt"],
  gtm: {
    id: process.env.NUXT_PUBLIC_GTM_ID || "",
    analytics: {
      applicationId: "product-a",
      environment: process.env.NUXT_PUBLIC_SITE_ENV || "development",
      autoCapture: {
        internalDomains: ["product.example"],
        modulePrefix: "product_",
        moduleRules: [{ selector: "header", module: "navigation" }],
      },
    },
  },
});

An empty id disables the integration by default. Setting enabled: true without an ID fails configuration instead of starting a partially configured runtime.

Options

| Option | Default | Purpose | | ---------------- | --------------------------------------------- | ------------------------------------------------------------------------ | | id | "" | GTM container ID matching GTM-[A-Z0-9]+ | | enabled | id.length > 0 | Enables script loading and the Google transport | | dataLayerName | "dataLayer" | Valid JavaScript identifier used by the GTM data layer | | defaultConsent | every storage category denied | Consent Mode defaults applied before the script loads | | grantedConsent | analytics and security granted; others denied | Consent applied after grant(); the script stays loaded | | script | {} | @nuxt/scripts bundle, proxy, Partytown, and warmup settings | | analytics | analytics module defaults | @stackonward/analytics-nuxt options, including context and autocapture |

Consent objects also accept region and wait_for_update; unknown option keys are rejected.

Consent lifecycle

The module loads GTM immediately under defaultConsent (Google Consent Mode). Granting updates Google consent to grantedConsent without waiting to load the script. Denying restores defaultConsent and keeps the script loaded. Grant or deny through the provider-neutral composable:

<script setup lang="ts">
const consent = useAnalyticsConsent();

function acceptAnalytics() {
  consent.grant();
}

function rejectAnalytics() {
  consent.deny();
}
</script>

Disposing the runtime removes the script. A missing @nuxt/scripts consent API or use after disposal fails with a typed lifecycle error instead of reporting success.

The product or consent-management platform owns persistence of the user's decision. Restore a saved grant or denial during application startup.

Generate the matching GTM container

Use stackonward analytics generate or @stackonward/google-tag-manager/container to create the matching GTM import artifact. Import it into a GTM web-container workspace, preview it, and publish the reviewed container version. This module never mutates Google account configuration.

Installed runtime

  • @stackonward/analytics-nuxt for tracking, context, consent, and autocapture
  • @nuxt/scripts for typed GTM script loading
  • @stackonward/google-tag-manager for event validation and data-layer projection
  • public runtime config under stackonwardGtm

Compatibility

  • Node.js 20 or newer
  • Nuxt >=3.15.0 <5
  • Vue >=3.5.0 <4
  • @nuxt/scripts >=1.3.0 <2

Related packages

  • @stackonward/analytics-nuxt is the provider-neutral Nuxt runtime.
  • @stackonward/google-tag-manager can be used without Nuxt.
  • @stackonward/cli generates declarative analytics provider artifacts.

License

MIT