Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics Setup #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
GA SETUP
  • Loading branch information
malithmcr committed Dec 22, 2020
commit b627b8a772b86c31b12d9ff38d412a45cf1e1a10
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"react": "^16.13.1",
"react-compound-slider": "^2.5.0",
"react-dom": "^16.13.1",
"react-ga": "^3.3.0",
"react-loading-skeleton": "^2.1.1",
"react-modal": "^3.11.2",
"react-phone-input-2": "^2.13.8",
Expand Down
12 changes: 9 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import React, { StrictMode } from 'react';
import React, { StrictMode, useEffect } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import AppRouter from 'routers/AppRouter';
import Preloader from 'components/ui/Preloader';
import ReactGA from "react-ga";

const App = ({ store, persistor }) => (

const App = ({ store, persistor }) => {
useEffect(()=>{
ReactGA.initialize('UA-128284894-4')
}, [])
return(
<StrictMode>
<Provider store={store}>
<PersistGate loading={<Preloader />} persistor={persistor}>
<AppRouter />
</PersistGate>
</Provider>
</StrictMode>
);
)};

export default App;
5 changes: 5 additions & 0 deletions src/routers/AppRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ import AdminRoute from './AdminRoute';
import Shop from 'views/shop';
import FeaturedProducts from 'views/featured';
import RecommendedProducts from 'views/recommended';
import ReactGA from "react-ga";

export const history = createBrowserHistory();

history.listen((location) => {
ReactGA.pageview(location.pathname);
});

const AppRouter = () => (
<Router history={history}>
<Switch>
Expand Down