File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 11module . exports = {
22 firebase : require ( './firebase/client' ) ,
3+ GA : {
4+ development : {
5+ trackingID : 'UA-86112397-2' ,
6+ } ,
7+ production : {
8+ trackingID : 'UA-86112397-1' ,
9+ } ,
10+ } ,
311} ;
Original file line number Diff line number Diff line change 112112 "react" : " ^15.3.2" ,
113113 "react-bootstrap" : " ^0.30.5" ,
114114 "react-dom" : " ^15.0.2" ,
115+ "react-ga" : " ^2.1.2" ,
115116 "react-helmet" : " ^3.0.2" ,
116117 "react-intl" : " ^2.1.2" ,
117118 "react-native" : " ^0.31.0" ,
Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ import rootReducer from '../common/reducers';
99import getRoutes from '../common/routes' ;
1010import setupLocale from './setupLocale' ;
1111import setupNProgress from './setupNProgress' ;
12+ import setupGA from './setupGA' ;
1213import { setApiEngine } from '../common/actions/apiEngine' ;
1314import ApiEngine from '../common/utils/ApiEngine' ;
1415
1516setupNProgress ( ) ;
1617setupLocale ( ) ;
18+ let logPageView = setupGA ( ) ;
1719const initialState = window . __INITIAL_STATE__ ;
1820let store = createStore ( rootReducer , initialState , applyMiddleware ( thunk ) ) ;
1921
@@ -34,7 +36,11 @@ match({
3436 render (
3537 < Provider store = { store } >
3638 < LocaleProvider >
37- < Router history = { browserHistory } { ...renderProps } >
39+ < Router
40+ history = { browserHistory }
41+ onUpdate = { logPageView }
42+ { ...renderProps }
43+ >
3844 { routes }
3945 </ Router >
4046 </ LocaleProvider >
Original file line number Diff line number Diff line change 1+ import reactGA from 'react-ga' ;
2+ import configs from '../../configs/project/client' ;
3+
4+ export default ( ) => {
5+ if ( configs . GA ) {
6+ reactGA . initialize ( configs . GA [ process . env . NODE_ENV ] . trackingID ) ;
7+
8+ return function logPageView ( ) {
9+ reactGA . set ( { page : window . location . pathname } ) ;
10+ reactGA . pageview ( window . location . pathname ) ;
11+ } ;
12+ }
13+ return undefined ;
14+ } ;
You can’t perform that action at this time.
0 commit comments