Skip to content

Commit 361eeff

Browse files
lbogdanCompuIves
authored andcommitted
Only send Google Analytics pageviews in production. (codesandbox#167)
1 parent 785141f commit 361eeff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/app/pages/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ class Routes extends React.PureComponent<Props> {
103103
<Route
104104
path="/"
105105
render={({ location }) => {
106-
routeDebugger(
107-
`Sending '${location.pathname + location.search}' to ga.`
108-
);
109-
if (typeof window.ga === 'function') {
110-
window.ga('set', 'page', location.pathname + location.search);
111-
window.ga('send', 'pageview');
106+
if (process.env.NODE_ENV === 'production') {
107+
routeDebugger(
108+
`Sending '${location.pathname + location.search}' to ga.`
109+
);
110+
if (typeof window.ga === 'function') {
111+
window.ga('set', 'page', location.pathname + location.search);
112+
window.ga('send', 'pageview');
113+
}
112114
}
113115
return null;
114116
}}

0 commit comments

Comments
 (0)