Giter VIP home page Giter VIP logo

nuxt-tiktok-pixel-module's Introduction

nuxt-tiktok-pixel-module

npm versionnpm js-standard-style

A NuxtJS module thats injects TikTok Pixel code with custom tracking functionality

Inspired by https://github.com/GuillaumeFerron/nuxt-tiktok-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()

For Custom Tracking, you can call the following:

this.$tiktok.track("AddToCart")

or

this.$tiktok.track("AddToCart",{value:1})

Module options

List of possible options in the module:

Option Default Required Description
pixel null true The pixel identifier provided by TikTok business.
disabled false false Disable 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:

Method Purpose Equivalent 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]

nuxt-tiktok-pixel-module's People

Contributors

alihamza1214 avatar

Watchers

 avatar

nuxt-tiktok-pixel-module's Issues

this.$tiktok.track is not a function

When attempting to use the track function to fire an event I get 'this.$tiktok.track is not a function' error. I get this error anywhere the module is used. Any ideas? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.