nuxt-linkedin-pixel-module

Nuxt plugin for LinkedIn pixel

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
nuxt-linkedin-pixel-module
501.0.25 years ago5 years agoMinified + gzip package size for nuxt-linkedin-pixel-module in KB

Readme

nuxt-linkedin-pixel-module
npm (scoped with tag) npm js-standard-style CircleCI
A NuxtJS module thats injects LinkedIn Pixel code

Inspired by https://github.com/WilliamDASILVA/nuxt-linkedin-pixel-module

Table of Contents ##

Requirements

  • npm or yarn
  • NuxtJS
  • NodeJS

Install

$ npm install --save nuxt-linkedin-pixel-module
// or
$ yarn add nuxt-linkedin-pixel-module

Getting Started

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
  },
}

Disabling the pixel (for GDPR)

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()

Module options

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().

LinkedIn pixel instance

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() |

License

MIT License