0.1.3 • Published 1 year ago

nuxt-snack-video-pixel-tracking-module v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

nuxt-snack-video-pixel-module

npm version npm js-standard-style

A NuxtJS module that injects Snack Video Pixel code with custom tracking functionality

Table of Contents

Requirements

  • npm or yarn
  • NuxtJS
  • NodeJS

Install

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

Getting Started

Add nuxt-snack-video-pixel-module to modules section of nuxt.config.js.

{
  modules: [
    // Simple usage
    'nuxt-snack-video-pixel-module',

    // With options
    ['nuxt-snack-video-pixel-module', {
      /* module options */
      pixel: 'SNACK_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:

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

this.$kwaiq.enable()

For Custom Tracking, you can call the following:

 this.$kwaiq.track("addToCart", {
    content_type: "product",
    content_id: this.product._id,
    content_name: this.product.name,
    currency: "PKR",
    price: this.calculatePrice,
    value: this.calculatePrice
});

or

this.$kwaiq.track("purchase", {
    content_type: "product",
    currency: "PKR",
    contents: this.calculateProductArray(this.order.items),
    value: this.order.amount.total,
});

Module options

List of possible options in the module:

OptionDefaultRequiredDescription
pixelnulltrueThe pixel identifier provided by Snack Video business.
disabledfalsefalseDisable the pixel by default when initialized. Can be enabled later through $kwaiq.enable().

License

MIT License

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago