1.1.0 • Published 2 years ago

nuxt-tiktok-pixel-module v1.1.0

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

nuxt-tiktok-pixel-module

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

A NuxtJS module thats injects TikTok Pixel code

Inspired by https://github.com/odroltd/nuxt-linkedin-pixel-module#readme

Table of Contents

Requirements

  • npm or yarn
  • NuxtJS
  • NodeJS

Install

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

Getting Started

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

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

    // With options
    ['nuxt-tiktok-pixel-module', {
      /* module options */
      pixel: 'TIKTOK_PIXEL_ID',
      disabled: false
    }],
 ]
}

or even

{
  modules: [
    'nuxt-tiktok-pixel-module',
  ],
  tiktok: {
    /* module options */
    pixel: 'TIKTOK_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-tiktok-pixel-module',
  ],
  tiktok: {
    ...
    disabled: true
  },
}

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

this.$tiktok.enable()

Module options

List of possible options in the module:

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

TikTok pixel instance

The tracking pixel instance is available on all vue component instances as $tiktok. 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$tiktok.init()

License

MIT License