react-moanalytics

Web Analytics

Usage no npm install needed!

<script type="module">
  import reactMoanalytics from 'https://cdn.skypack.dev/react-moanalytics';
</script>

README

react-analytics

This is a react module which can be used to include any analytics modules to track pageview and events in a website. Currently supported analytics: google analytics, mixpanel analytics and kissmetrics analytics

Installation

Install from NPM with: npm install react-moanalytics --save

Usage

Initializing react-analytics:

import { ReactAnalytics } from  'react-moanalytics';
ReactAnalytics.init(jsonData);
ReactAnalytics.pageview();

JSON Data Format:

{
    "GA": {
        "Enable":  "true",
        "gaTrackingID":"XXXXX"
    },
    "MA":{
        "Enable":  "true",
        "maTrackingID":"XXXXX"
    }
    "KA":{
        "Enable":  "false",
        "kaTrackingID":"XXXXX"
    },
    "debug": "true"
}

GA, MA and KA depicts google analytics, mixpanel analytics and kissmetrics analytics respectively.

Enable Property will identify corresponding analytics initilization.

TrackingID Corresponding analytics account tracking id.

debug: true To enable the logs.

Initializing react-analytics with user-id:

import { ReactAnalytics } from  'react-moanalytics';
ReactAnalytics.init(jsonData, userIdentity);
ReactAnalytics.pageview(); 

userIdentity Initializing analytic with user-id.

Tracking Pageviews:

ReactAnalytics.pageview();

pageview default called by init and event api.

Tracking Event:

ReactAnalytics.event(category, action, label);

Example:

ReactAnalytics.event("PRODUCT", "Product added to cart", "PRODUCT_PAGE")

Stop Tracking:

ReactAnalytics.stopTracking();

stopTracking disable tracking.