Skip to content

Instantly share code, notes, and snippets.

View MattJonesCreation's full-sized avatar

Matt Jones MattJonesCreation

View GitHub Profile
@MattJonesCreation
MattJonesCreation / googleanalytics.js
Last active April 2, 2019 12:59
Google Analytics Implementation for a Create React App Project
// utils/GoogleAnalytics.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactGA from 'react-ga';
import { Route } from 'react-router-dom';
class GoogleAnalytics extends Component {
componentDidMount () {
this.logPageChange(
this.props.location.pathname,
// index.js
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import UnauthorizedLayout from 'layouts/UnauthorizedLayout'
import ErrorLayout from 'layouts/ErrorLayout'
import AuthorizedLayout from 'layouts/AuthorizedLayout'
import AuthorizedRoute from 'custom-routes/AuthorizedRoute'
import GA from 'utils/GoogleAnalytics'