You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useAnalytics.js 377B

1234567891011121314
  1. import React, { useEffect } from 'react';
  2. import { useLocation } from 'react-router-dom';
  3. import ReactGA from 'react-ga';
  4. const useAnalytics = pageTitle => {
  5. const location = useLocation();
  6. useEffect(() => {
  7. ReactGA.pageview(location.pathname, null, pageTitle);
  8. console.log(`Google Analytics running for ${pageTitle}`);
  9. }, []);
  10. };
  11. export default useAnalytics;