mattgenious / react-snapchat-pixel

React JS wrapper for Snapchats Pixel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Snapchat Pixel

npm

React JS wrapper for Snapchat's Pixel

Its more or less a copy of react-facebook-pixel by Zain Sajjad but adapted for Snapchat's pixel.

Install

npm install react-snapchat-pixel

or

yarn add react-snapchat-pixel

How to use

import ReactPixel from 'react-snapchat-pixel';


const userIdentification = { user_email: 'some@email.com' }; // optional
const options = {
    debug: false, 		// enable logs
};
ReactPixel.init('yourPixelIdGoesHere', userIdentification, options);

ReactPixel.pageView(); 					// For tracking page view
ReactPixel.track( event, data ) 		// For tracking default events, more info about events and data https://businesshelp.snapchat.com/en-US/article/purchase-event

if you're bundling in CI

  ...
  componentDidMount() {
    const ReactPixel =  require('react-snapchat-pixel');
    ReactPixel.init('yourPixelIdGoesHere');
  }
  ...

otherwise CI will complain there's no window.

Dev Server

npm run start

Default dev server runs at localhost:8080 in browser. You can set IP and PORT in webpack.config.dev.js

Production Bundle

npm run bundle

About

React JS wrapper for Snapchats Pixel

License:MIT License


Languages

Language:JavaScript 100.0%