nuxt-linkedin-pixel-module

1.0.2 • Public • Published

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

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i nuxt-linkedin-pixel-module

    Weekly Downloads

    70

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.83 kB

    Total Files

    6

    Last publish

    Collaborators

    • mark-beeby