Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

elsewhencode/react-google-analytics

 
 

Repository files navigation

react-google-analytics

Adds the Google Analytics script to your page and exposes the ga tracking function as a module.

Usage:

var ga = require('react-google-analytics');
var GAInitiailizer = ga.Initializer;

// Use the initializer to add the script to your page somewhere.
var MyComponent = React.createClass({
  render: function() {
    return (
      <div>
        // SNIP
          <GAInitiailizer />
        // SNIP
      </div>
    );
  }
});

Elsewhere, use the ga function:

var ga = require('react-google-analytics');
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');

Packages

No packages published

Languages

  • CoffeeScript 58.8%
  • JavaScript 28.5%
  • HTML 12.7%