A NuxtJS module thats injects LinkedIn Pixel code
Inspired by https://github.com/WilliamDASILVA/nuxt-linkedin-pixel-module
- npm or yarn
- NuxtJS
- NodeJS
$ npm install --save nuxt-linkedin-pixel-module
// or
$ yarn add nuxt-linkedin-pixel-module
Add nuxt-linkedin-pixel-module
to modules
section of nuxt.config.js
.
{
modules: [
// Simple usage
'nuxt-linkedin-pixel-module',
// With options
['nuxt-linkedin-pixel-module', {
/* module options */
partnerId: 'LINKEDIN_PIXEL_ID',
disabled: false
}],
]
}
or even
{
modules: [
'nuxt-linkedin-pixel-module',
],
linkedin: {
/* module options */
partnerId: 'LINKEDIN_PIXEL_ID',
disabled: false
},
}
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:
{
modules: [
'nuxt-linkedin-pixel-module',
],
linkedin: {
...
disabled: true
},
}
Now, in your component, you can call the following in order to start the pixel and track the current page.
this.$li.enable()
List of possible options in the module:
Option | Default | Required | Description |
---|---|---|---|
partnerId | null | true | The unique insight tag ID (usually 6 digits) identifier provided by LinkedIn (can be located within the Set up your insight Tag dialog displayed as: __linkedin_partner_id = "xxxxxx"; . |
disabled | false | false | Disable the Pixel by default when initialized. Can be enabled later through $li.enable() . |
The tracking pixel instance is available on all vue component instances as $li. 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 |
$li.init() |