react-ga-hoc

Send GA pageview safely with async data.

Usage no npm install needed!

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

README

react-ga-hoc

Send GA pageview safely with async data.

Travis Codecov Status npm package npm downloads license

Dependency Status devDependency Status peerDependency Status

Installation

$ npm install react-ga react-ga-hoc --save

Usage

  • As HOC
import ga from 'react-ga';
import { pageview } from 'react-ga-hoc';

// SDK Setup
ga.initialize('id');

// Use HOC with Container
pageview(path)(
  () => <div/>,
);
  • ES7 decorator
@pageview()
class Container extends React.Component {
  render() {
    return <div/>;
  }
}

API

pageview(
  ?path: string,
): HigherOrderComponent
Arguments Default Description
path current path path to be sent a pageview

Test

$ npm run lint
$ npm run test:watch

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ npm test).

CHANGELOG

LICENSE

MIT: http://michaelhsu.mit-license.org