regexper-static/src/setup/analytics.js

15 lines
438 B
JavaScript

import ReactGA from 'react-ga';
const setupAnalytics = () => {
if (navigator.doNotTrack !== '1' && window.doNotTrack !== '1') {
ReactGA.initialize(process.env.GA_PROPERTY, {
debug: (process.env.NODE_ENV !== 'production')
});
ReactGA.pageview(document.location.pathname);
} else {
console.log('Google Analytics disabled by Do Not Track'); // eslint-disable-line no-console
}
};
export default setupAnalytics;