
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
@forked-prs/nuxt-facebook-pixel-module
Advanced tools
A NuxtJS module thats injects Facebook Pixel code
@forked-prs/nuxt-facebook-pixel-module
dependency to your projectyarn add --dev @forked-prs/nuxt-facebook-pixel-module # or npm install --save-dev @forked-prs/nuxt-facebook-pixel-module
@forked-prs/nuxt-facebook-pixel-module
to the buildModules
section of nuxt.config.js
export default {
buildModules: [
['@forked-prs/nuxt-facebook-pixel-module', {
track: 'PageView',
pixelId: 'FACEBOOK_PIXEL_ID',
disabled: false,
debug: false,
}]
]
}
:warning: If you are using Nuxt < v2.9 you have to install the module as a dependency
(No --dev
or --save-dev
flags) and use modules
section in nuxt.config.js
instead of buildModules
.
export default {
buildModules: [
'@forked-prs/nuxt-facebook-pixel-module'
],
facebook: {
track: 'PageView',
pixelId: 'FACEBOOK_PIXEL_ID',
}
}
You can use 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.
export default {
buildModules: [
'@forked-prs/nuxt-facebook-pixel-module'
],
facebook: {
pixelId: '123456789012345', // Used as fallback if no runtime config is provided
},
publicRuntimeConfig: {
facebook: {
/* module options */
pixelId: process.env.FB_PIXEL_ID || 'some-staging-key',
disabled: false,
debug: !!process.env.FB_PIXEL_DEBUG,
}
},
}
If 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:
{
buildModules: [
'@forked-prs/nuxt-facebook-pixel-module',
],
facebook: {
...
disabled: true
},
}
By Default it is disabled in development mode
you can set
debug: true
to enable while in dev or if using conjuction with runtimeconfig you can set FB_PIXEL_DEBUG=true
in your .env
Now, in your component, you can call the following in order to start the pixel and track the current page.
this.$fb.enable()
List of possible options in the module:
Option | Default | Required | Description |
---|---|---|---|
pixelId | null | true | The unique pixel identifier provided by Facebook. |
track | PageView | false | Default tracking event. |
version | 2.0 | false | Tracking version. |
disabled | false | false | Disable the Pixel by default when initialized. Can be enabled later through $fb.enable() . |
The tracking pixel instance is available on all vue component instances as $fb. It has the following methods:
Method | Purpose | Equivalent to |
---|---|---|
enable() | If you had previously set disabled: true in config, enables the pixel and tracks the current page view | $fb.init(), $fb.track() |
init() | Initialises the pixel | fbq('init', <options.pixelId>) |
track(event, parameters) | Sends a track event with optional parameters . It's PageView by default if the event is not defined. | fbq('track', <options.track>, parameters) |
query(key, value, parameters) | Call the underlying fbq instance with anything else. The parameters attribute is optional. | fbq(key, value, parameters) |
FAQs
Nuxt plugin for Facebook pixel
We found that @forked-prs/nuxt-facebook-pixel-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.