Skip to content

Commit e91713c

Browse files
author
Christopher Willis-Ford
committed
initialize Google Analytics only if GA_ID is set
1 parent dee7462 commit e91713c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib/analytics.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import GoogleAnalytics from 'react-ga';
22

3-
GoogleAnalytics.initialize(process.env.GA_ID || window.GA_ID, {
4-
debug: (process.env.NODE_ENV !== 'production'),
5-
titleCase: true,
6-
sampleRate: (process.env.NODE_ENV === 'production') ? 100 : 0,
7-
forceSSL: true
8-
});
3+
const GA_ID = (process.env.GA_ID || window.GA_ID);
4+
if (GA_ID) {
5+
GoogleAnalytics.initialize(GA_ID, {
6+
debug: (process.env.NODE_ENV !== 'production'),
7+
titleCase: true,
8+
sampleRate: (process.env.NODE_ENV === 'production') ? 100 : 0,
9+
forceSSL: true
10+
});
11+
}
912

1013
export default GoogleAnalytics;

0 commit comments

Comments
 (0)