Skip to content

Commit

Permalink
구글 애널리틱스 삽입 (#641)
Browse files Browse the repository at this point in the history
feat: 구글 애널리틱스 추가
  • Loading branch information
gyeongza authored Oct 10, 2023
1 parent c290f45 commit af8d9a9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
65 changes: 61 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"@types/react-dom": "^18.2.6",
"core-js": "^3.31.1",
"dotenv": "^16.3.1",
"history": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-router-dom": "^6.14.2",
"styled-components": "^6.0.4"
},
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ import LoadingPage from './pages/LoadingPage';
import ModalProvider from './contexts/ModalContext';
import { QueryClientProvider } from '@tanstack/react-query';
import { queryClient } from './hooks/query/queryClient';
import ReactGA from 'react-ga';
import { createBrowserHistory } from 'history';

const gaTrackingId = process.env.REACT_APP_GA_TRACKING_ID;
if (gaTrackingId) {
ReactGA.initialize(gaTrackingId);
}

const history = createBrowserHistory();
history.listen((response: { location: { pathname: string } }) => {
console.log(response.location.pathname);
ReactGA.set({ page: response.location.pathname });
ReactGA.pageview(response.location.pathname);
});

const App = () => {
ChannelService.loadScript();
Expand Down

0 comments on commit af8d9a9

Please sign in to comment.