1.1.4 • Published 2 years ago

@dukanify/nuxt-multiple-facebook-pixel-module v1.1.4

Weekly downloads
11
License
MIT
Repository
github
Last release
2 years ago

nuxt-multiple-facebook-pixel-module

npm (scoped with tag) npm js-standard-style

A NuxtJS module thats injects Multiple Facebook Pixel code

Table of Contents

Requirements

  • npm or yarn
  • NuxtJS
  • NodeJS

Install

$ npm install --save @dukanify/nuxt-multiple-facebook-pixel-module
// or
$ yarn add @dukanify/nuxt-multiple-facebook-pixel-module

Getting Started

Add @dukanify/nuxt-multiple-facebook-pixel-module to modules section of nuxt.config.js.

{
  modules: [
    // Simple usage
    '@dukanify/nuxt-multiple-facebook-pixel-module',

    // With options
    ['@dukanify/nuxt-multiple-facebook-pixel-module', {
      /* module options */
      track: 'PageView',
      pixelId: ['FACEBOOK_PIXEL_ID_1,ID_2'],
      disabled: false
    }],
 ]
}

or even

{
  modules: [
    '@dukanify/nuxt-multiple-facebook-pixel-module',
  ],
  facebook: {
    /* module options */
    track: 'PageView',
    pixelId: ['FACEBOOK_PIXEL_ID_1,ID_2'],
    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: [
    '@dukanify/nuxt-multiple-facebook-pixel-module',
  ],
  facebook: {
    ...
    disabled: true
  },
}

Now, in your component, you can call the following in order to start the pixel and track the current page.

this.$fb.enable()

Module options

List of possible options in the module:

OptionDefaultRequiredDescription
pixelIdnulltrueThe unique pixel identifier provided by Facebook.
trackPageViewfalseDefault tracking event.
version2.0falseTracking version.
disabledfalsefalseDisable the Pixel by default when initialized. Can be enabled later through $fb.enable().

Facebook pixel instance

The tracking pixel instance is available on all vue component instances as $fb. It has the following methods:

MethodPurposeEquivalent 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 pixelfbq('init', <options.pixelId>)
track(event)Sends a track event. It's PageView by default if the event is not defined.fbq('track', <options.track>)
query(key, value, parameters)Call the underlying fbq instance with anything else. The parameters attribute is optional.fbq(key, value, parameters)

New EventId tracking option added for handling deduplication if you are using server side events (CAPI)

this.$fb.track("Purchase", params,{eventID: 'purchase.123'});

License

MIT License

Thanks

Thanks to William DASILVA for his original Nuxt facebook pixel module which inspired this project.

1.1.4

2 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago