{"id":13506542,"url":"https://github.com/nuxt-community/gtm-module","last_synced_at":"2025-05-14T17:03:12.917Z","repository":{"id":39670297,"uuid":"239297290","full_name":"nuxt-community/gtm-module","owner":"nuxt-community","description":"Google Tag Manager Module for Nuxt.js","archived":false,"fork":false,"pushed_at":"2025-05-12T17:42:24.000Z","size":393,"stargazers_count":328,"open_issues_count":98,"forks_count":70,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-12T18:45:01.403Z","etag":null,"topics":["analytics","google-tag-manager","gtm","module","nuxt","nuxtjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuxt-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-09T12:00:52.000Z","updated_at":"2025-05-09T07:06:51.000Z","dependencies_parsed_at":"2023-09-24T17:56:34.268Z","dependency_job_id":"a9339f9a-3b8d-48d1-910e-de85145c054e","html_url":"https://github.com/nuxt-community/gtm-module","commit_stats":{"total_commits":62,"total_committers":16,"mean_commits":3.875,"dds":0.6129032258064516,"last_synced_commit":"ae9199e6cab39485bcc85758bdfb36ebace3cdcf"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fgtm-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fgtm-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fgtm-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-community%2Fgtm-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxt-community","download_url":"https://codeload.github.com/nuxt-community/gtm-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805847,"owners_count":21967053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","google-tag-manager","gtm","module","nuxt","nuxtjs"],"created_at":"2024-08-01T01:00:53.465Z","updated_at":"2025-05-14T17:03:12.858Z","avatar_url":"https://github.com/nuxt-community.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","JavaScript"],"sub_categories":["Uncategorized"],"readme":"# @nuxtjs/gtm\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Checks][checks-src]][checks-href]\n[![Codecov][codecov-src]][codecov-href]\n[![License][license-src]][license-href]\n\n\u003e Google Tag Manager Module for Nuxt.js\n\n[📖 **Release Notes**](./CHANGELOG.md)\n\nℹ️ If coming from v1 (`@nuxtjs/google-tag-manager`) please read v2 [release notes](https://github.com/nuxt-community/gtm-module/releases/tag/v2.0.0).\n\n## Setup\n\n1. Add `@nuxtjs/gtm` dependency to your project\n\n```bash\nyarn add @nuxtjs/gtm # or npm install @nuxtjs/gtm\n```\n\n2. Add `@nuxtjs/gtm` to the `modules` section of `nuxt.config.js`\n\n```js\nexport default {\n  modules: [\n    '@nuxtjs/gtm',\n  ],\n  gtm: {\n    id: 'GTM-XXXXXXX'\n  }\n}\n```\n### Runtime Config\n\nYou can use [runtime config](https://nuxtjs.org/guide/runtime-config) if need to use dynamic environment variables in production. Otherwise, the options will be hardcoded during the build and won't be read from `nuxt.config` anymore.\n\n```js\nexport default {\n  modules: [\n    '@nuxtjs/gtm'\n  ],\n\n  gtm: {\n    id: 'GTM-XXXXXXX', // Used as fallback if no runtime config is provided\n  },\n\n  publicRuntimeConfig: {\n    gtm: {\n      id: process.env.GOOGLE_TAG_MANAGER_ID\n    }\n  },\n}\n```\n\n## Options\n\nDefaults:\n\n```js\nexport default {\n  gtm: {\n    enabled: undefined, /* see below */\n    debug: false,\n\n    id: undefined,\n    layer: 'dataLayer',\n    variables: {},\n\n    pageTracking: false,\n    pageViewEventName: 'nuxtRoute',\n\n    autoInit: true,\n    respectDoNotTrack: true,\n\n    scriptId: 'gtm-script',\n    scriptDefer: false,\n    scriptURL: 'https://www.googletagmanager.com/gtm.js',\n    crossOrigin: false,\n\n    noscript: true,\n    noscriptId: 'gtm-noscript',\n    noscriptURL: 'https://www.googletagmanager.com/ns.html'\n  }\n}\n```\n\n### `enabled`\n\nGTM module uses a debug-only version of `$gtm` during development (`nuxt dev`).\n\nYou can explicitly enable or disable it using `enabled` option:\n\n```js\nexport default {\n  gtm: {\n    // Always send real GTM events (also when using `nuxt dev`)\n    enabled: true\n  }\n}\n```\n\n### `debug`\n\nWhether `$gtm` API calls like `init` and `push` are logged to the console.\n\n### Manual GTM Initialization\n\nThere are several use cases that you may need more control over initialization:\n\n- Block Google Tag Manager before user directly allows (GDPR realisation or other)\n- Dynamic ID based on request path or domain\n- Initialize with multi containers\n- Enable GTM on page level\n\n`nuxt.config.js`:\n\n```js\nexport default {\n modules: [\n  '@nuxtjs/gtm'\n ],\n plugins: [\n  '~/plugins/gtm'\n ]\n}\n```\n\n`plugins/gtm.js`:\n\n```js\nexport default function({ $gtm, route }) {\n  $gtm.init('GTM-XXXXXXX')\n}\n```\n\n- **Note:** All events will be still buffered in data layer but won't send until `init()` method getting called.\n- **Note:** Please consult with [Google Tag Manager Docs](https://developers.google.com/tag-manager/devguide#multiple-containers) for more information caveats using multiple containers.\n\n### Router Integration\n\nYou can optionally set `pageTracking` option to `true` to track page views.\n\n**Note:** This is disabled by default to prevent double events when using alongside with Google Analytics so take care before enabling this option.\n\nThe default event name for page views is `nuxtRoute`, you can change it by setting the `pageViewEventName` option.\n\n## Usage\n\n### Pushing events\n\nYou can push events into the configured layer:\n\n```js\nthis.$gtm.push({ event: 'myEvent', ...someAttributes })\n```\n\n## Development\n\n1. Clone this repository\n2. Install dependencies using `yarn install` or `npm install`\n3. Start development server using `yarn dev` or `GTM_ID=\u003cyour gtm id\u003e yarn dev` if you want to provide custom GTM_ID.\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright (c) Nuxt.js Community\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/gtm/latest.svg?style=flat-square\n[npm-version-href]: https://npmjs.com/package/@nuxtjs/gtm\n\n[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/gtm.svg?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/gtm\n\n[checks-src]: https://img.shields.io/github/workflow/status/nuxt-community/gtm-module/test/master?style=flat-square\n[checks-href]: https://github.com/nuxt-community/gtm-module/actions\n\n[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/gtm-module.svg?style=flat-square\n[codecov-href]: https://codecov.io/gh/nuxt-community/gtm-module\n\n[license-src]: https://img.shields.io/npm/l/@nuxtjs/gtm.svg?style=flat-square\n[license-href]: https://npmjs.com/package/@nuxtjs/gtm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-community%2Fgtm-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxt-community%2Fgtm-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-community%2Fgtm-module/lists"}