0.1.0 • Published 6 years ago

react-strata v0.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

An analytics module for React.

Requirements

  • React 0.14+

Browser Requirements

  • IE10+

Features

  • Unobtrusive feature injection through a root application component.
  • Supports page view tracking.
  • Supports both imperative and declarative custom link tracking.
  • Provides a custom event tracking API.
  • Supports multiple simultaneous analytics vendor tracking.

Installation

$ npm install --save react-metrics

React Metrics depends on Promise to be available in browser. If your application support the browser which doesn't support Promise, please include the polyfill.

Getting Started

1. Configure Metrics

Refer to the docs for more information on configuration.

// App.js
import {AnalyticsProvider} from "merge-analytics";

const config = {
    vendors: [{
        name: "Google Analytics",
        api: new GoogleAnalytics({
            trackingId: "UA-********-*"
        })
    }],
    pageViewEvent: "pageLoad",
    pageDefaults: () => {
        return {
            siteName: "My Web Site",
            ...
        };
    }
}

2. Wrap Application Level Component

Compose your top level application component with metrics in order to provide metrics to all components and automatically enable page view tracking.

// App.js

class Application extends React.Component {
    render() {
        return (
            <AnalyticsProvider>
                { /* The rest of your app */ }
            </AnalyticsProvider>
        );
    }
}
export default metrics(config)(Application);

3. Track Page Views

4. Custom Event Tracking

4. Analytics Vendor Implementations

react-metrics does not automatically supply any vendor analytics. You need to integrate with an analytics vendor to actually track something for reporting. Refer to Vendor Examples for Omniture, Google Analytics and other implementations.