Skip to content

Commit 75de615

Browse files
committed
fix(gtag): app doesn't crash without providing a GA tokeen
1 parent f7f479c commit 75de615

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

pages/_document.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default class extends Document<Props> {
2727
render() {
2828
const language = 'en';
2929
const {isProduction} = this.props;
30-
console.log(GA_TRACKING_ID, isProduction);
3130

3231
return (
3332
<html lang={language}>
@@ -37,17 +36,14 @@ export default class extends Document<Props> {
3736
<meta name="viewport" content="width=device-width, initial-scale=1"/>
3837

3938
{/* Global Site Tag (gtag.js) - Google Analytics */}
40-
{/* We only want to add the scripts if in production */}
41-
{isProduction && (
42-
<Fragment>
43-
<script
44-
async
45-
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
46-
/>
47-
{/* We call the function above to inject the contents of the script tag */}
48-
<script dangerouslySetInnerHTML={this.setGoogleTags(GA_TRACKING_ID)}/>
49-
</Fragment>
50-
)}
39+
<Fragment>
40+
<script
41+
async
42+
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
43+
/>
44+
{/* We call the function above to inject the contents of the script tag */}
45+
<script dangerouslySetInnerHTML={this.setGoogleTags(GA_TRACKING_ID)}/>
46+
</Fragment>
5147

5248
</Head>
5349
<body>

0 commit comments

Comments
 (0)