티스토리 뷰
React-google analytics 달기
> ReactGA npm 사용하기
https://milooy.wordpress.com/2016/01/14/google-analtyics-2-google-tag-manager/ 참고
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
// import { BrowserRouter } from 'react-router-dom';
import { AppContainer } from 'react-hot-loader';
import createHistory from 'history/createBrowserHistory';
import App from 'src/App';
import createNewStore from 'src/redux/createNewStore';
import registerServiceWorker from './registerServiceWorker';
import './index.scss';
const history = createHistory();
const store = createNewStore(history);
const ReactGA = require('react-ga');
ReactGA.initialize('UA-69160528-10', { debug: true });
const onUpdate = () => {
ReactGA.set({ page: window.location.pathname });
ReactGA.pageview(window.location.pathname);
};
const render = Component => {
ReactDOM.render(
<AppContainer>
<Provider store={store}>
<ConnectedRouter onUpdate={onUpdate} history={history}>
<Component />
</ConnectedRouter>
</Provider>
</AppContainer>,
document.getElementById('root')
);
};
render(App);
if (module.hot) {
module.hot.accept('src/App', () => {
render(App);
});
}
registerServiceWorker();
'Front end > React' 카테고리의 다른 글
React - 리덕스 미들웨어 (0) | 2018.03.02 |
---|---|
Redux- 리덕스 총정리하기 (0) | 2018.03.02 |
React-Link to로 화면전환시 맨위로 스크롤가게하기 (0) | 2018.02.21 |
리액트 -What is react? (1) | 2018.02.14 |
리액트-Redux (0) | 2018.02.09 |
댓글