{"id":15486089,"url":"https://github.com/williamdasilva/nuxt-facebook-pixel-module","last_synced_at":"2025-04-06T10:11:22.879Z","repository":{"id":39544689,"uuid":"109678263","full_name":"WilliamDASILVA/nuxt-facebook-pixel-module","owner":"WilliamDASILVA","description":"Inject Facebook pixel code","archived":false,"fork":false,"pushed_at":"2023-07-17T21:10:48.000Z","size":845,"stargazers_count":88,"open_issues_count":18,"forks_count":41,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-04-04T21:42:17.814Z","etag":null,"topics":["facebook","module","nuxt-module","nuxtjs","vuejs"],"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/WilliamDASILVA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-11-06T10:05:39.000Z","updated_at":"2025-02-21T15:49:49.000Z","dependencies_parsed_at":"2024-06-18T22:41:58.968Z","dependency_job_id":"bd7cb17c-a16e-4b28-bc8c-df21df9a1562","html_url":"https://github.com/WilliamDASILVA/nuxt-facebook-pixel-module","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WilliamDASILVA%2Fnuxt-facebook-pixel-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WilliamDASILVA%2Fnuxt-facebook-pixel-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WilliamDASILVA%2Fnuxt-facebook-pixel-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WilliamDASILVA%2Fnuxt-facebook-pixel-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WilliamDASILVA","download_url":"https://codeload.github.com/WilliamDASILVA/nuxt-facebook-pixel-module/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464222,"owners_count":20942970,"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":["facebook","module","nuxt-module","nuxtjs","vuejs"],"created_at":"2024-10-02T06:06:18.418Z","updated_at":"2025-04-06T10:11:22.836Z","avatar_url":"https://github.com/WilliamDASILVA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nuxt-facebook-pixel-module\n\n[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-facebook-pixel-module/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-facebook-pixel-module)\n[![npm](https://img.shields.io/npm/dt/nuxt-facebook-pixel-module.svg?style=flat-square)](https://npmjs.com/package/nuxt-facebook-pixel-module)\n[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com)\n[![CircleCI](https://img.shields.io/circleci/project/github/WilliamDASILVA/nuxt-facebook-pixel-module/master.svg?style=flat-square)](https://circleci.com/gh/WilliamDASILVA/nuxt-facebook-pixel-module/tree/master)\n\n\u003e A NuxtJS module thats injects Facebook Pixel code\n\n## Table of Contents\n\n* [Requirements](#requirements)\n* [Install](#install)\n* [Getting Started](#getting-started)\n* [License](#license)\n\n## Requirements\n\n* npm or yarn\n* NuxtJS\n* NodeJS\n\n## Install\n\n```bash\n$ npm install --save nuxt-facebook-pixel-module\n// or\n$ yarn add nuxt-facebook-pixel-module\n```\n\n## Getting Started\n\nAdd `nuxt-facebook-pixel-module` to `modules` section of `nuxt.config.js`.\n\n```js\n{\n  modules: [\n    // Simple usage\n    'nuxt-facebook-pixel-module',\n\n    // With options\n    ['nuxt-facebook-pixel-module', {\n      /* module options */\n      track: 'PageView',\n      pixelId: 'FACEBOOK_PIXEL_ID',\n      autoPageView: true,\n      disabled: false\n    }],\n ]\n}\n```\n\nor even\n\n```js\n{\n  modules: [\n    'nuxt-facebook-pixel-module',\n  ],\n  facebook: {\n    /* module options */\n    track: 'PageView',\n    pixelId: 'FACEBOOK_PIXEL_ID',\n    autoPageView: true,\n    disabled: false\n  },\n}\n```\n\n## Automatically track PageView\n\nBy default, the module won't trigger any tracking event on route change. To enable this behaviour, you must specify the `autoPageView` option and set to `true` in the Nuxt module options.\n\n```js\n{\n  modules: [\n    'nuxt-facebook-pixel-module',\n  ],\n  facebook: {\n    /* module options */\n    pixelId: 'FACEBOOK_PIXEL_ID',\n    autoPageView: true\n  },\n}\n```\n\n## Disabling the pixel (for GDPR)\n\nIf you'd like to install the pixel disabled, and enable it later after the user has consented to its use, you can do so by setting `disabled: true` in the pixel configuration:\n\n```js\n{\n  modules: [\n    'nuxt-facebook-pixel-module',\n  ],\n  facebook: {\n    ...\n    disabled: true\n  },\n}\n```\n\nNow, in your component, you can call the following in order to start the pixel and track the current page.\n\n```js\nthis.$fb.enable()\n```\n\nThe pixel can be disabled again later on by using the `.disable()` method.\n\n## Multiple pixel codes according to route\n\nIt's possible to use multiple pixel codes according to the user's route. This can be made through the `pixels` property.\nThe `pixels` property expects an array of options.\n\n```js\n{\n  modules: [\n    'nuxt-facebook-pixel-module',\n  ],\n  facebook: {\n    pixelId: 'DEFAULT_PIXEL_ID',\n    pixels: [\n      {\n        pixelId: 'FACEBOOK_PIXEL_ID',\n        routes: [\n          '/my-custom-route',\n          '/hello/*'\n        ]\n      }\n    ]\n  },\n}\n```\n\nPer this example, whenever the user is on the `/my-custom-route`, it will use the `FACEBOOK_PIXEL_ID` instead of the `DEFAULT_PIXEL_ID`. For all the other routes, it will use the default one.\n\nNote : Since the `pixels` property is an array of options, any other valid option (`track`, `manualMode`, ...) can be passed.\n\n# Advanced Matching\nTo send custom user data when initializing the FB Pixel you'll have to disable the plugin in your Nuxt config file and enable it once you've set the user data.\n\nRun the following from your Vue component once you've access to the user data:\n```javascript\nthis.$fb.setUserData({ external_id: 32323, fn: 'John' })\nthis.$fb.enable()\n```\n\nRead more about [Advanced Matching](https://developers.facebook.com/docs/facebook-pixel/advanced/advanced-matching).\n\n## Module options\n\nList of possible options in the module:\n\n| Option   | Default  | Required | Description                                                                               |\n|----------|----------|----------|-------------------------------------------------------------------------------------------|\n| pixelId  | null     | true     | The unique pixel identifier provided by Facebook.                                         |\n| track    | PageView | false    | Default tracking event.                                                                   |\n| version  | 2.0      | false    | Tracking version.                                                                         |\n| disabled | false    | false    | Disable the Pixel by default when initialized. Can be enabled later through `$fb.enable()` and disabled again with `$fb.disable()`.\n| debug | false    | false    | By default, tracking in development mode is disabled. By specifying `true`, you manually allow tracking in development mode.\n| manualMode | false    | false    | By default, Facebook will trigger button click and page metadata. Set to `true` to disable this behaviour. [See more informations](https://developers.facebook.com/docs/facebook-pixel/advanced/#automatic-configuration)\n| autoPageView | false    | false    | If set to `true`, automatically triggers a `PageView` track event on every page change.\n| pixels | []    | false    | An array of pixels be used according to a specific set of routes. See [Multiple pixel codes according to route](#multiple-pixel-codes-according-to-route)\n\n## Facebook pixel instance\n\nThe tracking pixel instance is available on all vue component instances as $fb. It has the following methods:\n\n| Method            | Purpose                                                                                                  | Equivalent to                  |\n|-------------------|----------------------------------------------------------------------------------------------------------|--------------------------------|\n| enable()          | If you had previously set `disabled: true` in config, enables the pixel and tracks the current page view | $fb.init(), $fb.track()        |\n| disable()          | Disables the pixel again |         |\n| setPixelId()            | Change the default pixelId \u0026 trigger an init it                                                                                    | |\n| setUserData(userData) | Used to set user data that'll be used once the `fbq` init function is called. See [Advanced Matching](https://developers.facebook.com/docs/facebook-pixel/advanced/advanced-matching). | |\n| init()            | Initialises the pixel                                                                                    | fbq('init', \u003coptions.pixelId\u003e) |\n| track(event, parameters)           | Sends a track event with optional `parameters`. It's `PageView` by default if the `event` is not defined.                                                                                      | fbq('track', \u003coptions.track\u003e, parameters)  |\n| query(key, value, parameters) | Call the underlying fbq instance with anything else. The `parameters` attribute is optional.                                                      | fbq(key, value, parameters)                |\n\n## License\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamdasilva%2Fnuxt-facebook-pixel-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamdasilva%2Fnuxt-facebook-pixel-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamdasilva%2Fnuxt-facebook-pixel-module/lists"}