Adding Google Analytics

This commit is contained in:
Jeff Avallone 2018-02-11 10:27:43 -05:00
parent 214a9eb5c1
commit fd5a8786d0
5 changed files with 25 additions and 1 deletions

View File

@ -49,6 +49,7 @@
"precss": "^3.1.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-ga": "^2.4.1",
"react-test-renderer": "^16.2.0",
"style-loader": "^0.20.1",
"svg-react-loader": "^0.4.5",

10
src/analytics.js Normal file
View File

@ -0,0 +1,10 @@
import ReactGA from 'react-ga';
const setupGA = () => {
ReactGA.initialize(process.env.GA_PROPERTY, {
debug: (process.env.NODE_ENV !== 'production')
});
ReactGA.pageview(document.location.pathname);
};
export { setupGA };

View File

@ -1 +1,4 @@
import '../../style.css';
import { setupGA } from '../../analytics';
setupGA();

View File

@ -5,5 +5,8 @@ import App from '../../components/App';
import '../../style.css';
import '../../service-worker';
import { setupGA } from '../../analytics';
setupGA();
ReactDOM.render(<App/>, document.getElementById('root'));

View File

@ -6244,6 +6244,13 @@ react-dom@^16.2.0:
object-assign "^4.1.1"
prop-types "^15.6.0"
react-ga@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-2.4.1.tgz#dfbd5f028ed39a07067f7a8bf57dc0d240000767"
optionalDependencies:
prop-types "^15.6.0"
react "^15.6.2 || ^16.0"
react-test-renderer@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.2.0.tgz#bddf259a6b8fcd8555f012afc8eacc238872a211"
@ -6252,7 +6259,7 @@ react-test-renderer@^16.2.0:
object-assign "^4.1.1"
prop-types "^15.6.0"
react@^16.2.0:
"react@^15.6.2 || ^16.0", react@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
dependencies: