react-tracking-facebook

0.3.5 • Public • Published

React Tracking Facebook

Build Status dependencies Status devDependencies Status License: MIT

Un-official module to easily add Facebook pageview tracking to react apps. It functions as a tiny wrapper for the native script tag and window api. After initialization the Facebook script is injected into the document.

Installation

With npm:

npm install react-tracking-facebook --save

Usage

Before tracking any page views or events the tracker needs to be imported and initialized with the custom tracking id:

import FacebookTracking from 'react-tracking-facebook';
FacebookTracking.initialize('TRACKING_ID');

After initializing page views can be tracked like this:

FacebookTracking.trackPageview();

There is the option to track standard events with event action and event args:

FacebookTracking.trackEvent(eventAction, eventArgs);

There is also the option to track custom events with event action and event args:

FacebookTracking.trackCustomEvent(eventAction, eventArgs);

There is also a method to expose the raw fbq tracking object api from the window:

FacebookTracking.getTracker();

How this works

This modules takes care of injecting the provider specific tracking script into the document and provides a tiny wrapper for the tracking api. It also exposes the tracker object api for direct access.

Documentation for the raw tracker api can be found here.

/react-tracking-facebook/

    Package Sidebar

    Install

    npm i react-tracking-facebook

    Weekly Downloads

    0

    Version

    0.3.5

    License

    MIT

    Unpacked Size

    8.92 kB

    Total Files

    7

    Last publish

    Collaborators

    • realalexbarge