use-tracker
Easily add google analytics tracking (https://github.com/react-ga/react-ga) to your React pages
Installation
npm install --save use-tracker
Initializing - done at the top level before any Routing is done
; // Use your GA tracking ID;
Importing the hook
Usage
use-tracker is powered by React Google Analytics in the background. Simply use the hook and provide a pathname and/or search string, and thats it.
import React from 'react';import useTracker from 'use-tracker'; { ; return ... }
It works perfectly with React Router
import React from 'react';import useTracker from 'use-tracker'; { ; return ... }