-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
34 lines (32 loc) · 918 Bytes
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* globals process */
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
import React from 'react'
import { oneLine } from 'common-tags'
// Google GST (gtag.js):
// https://github.com/gatsbyjs/gatsby/issues/8341
export const onRenderBody = ({ setHeadComponents }) => {
const GST_ID = 'AW-1013744060'
if (process.env.NODE_ENV === `production`) {
setHeadComponents([
<script
key="google-gst-js"
async
src={`https://www.googletagmanager.com/gtag/js?id=${GST_ID}`}
/>,
<script
key="google-gst-init"
dangerouslySetInnerHTML={{
__html: oneLine`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GST_ID}');`,
}}
/>,
])
}
}