-
Notifications
You must be signed in to change notification settings - Fork 3
/
gatsby-ssr.js
36 lines (34 loc) · 1.06 KB
/
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
35
36
/* globals process */
/* eslint react/no-danger: 0 */
/**
* 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) for GA4:
// https://github.com/gatsbyjs/gatsby/issues/8341
export const onRenderBody = ({ setHeadComponents }) => {
if (process.env.NODE_ENV === `production`) {
setHeadComponents([
<script
key="gtag-ga4"
async
src="https://www.googletagmanager.com/gtag/js?id=G-LDFLQCKVHG"
/>,
<script
key="gtag-ga4-config"
dangerouslySetInnerHTML={{
__html: oneLine`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-LDFLQCKVHG');
gtag('config', 'G-LDFLQCKVHG',{'tfac_app_version':'homepage'});`,
}}
/>,
<script src="https://www.googleoptimize.com/optimize.js?id=OPT-PDTTMLD" />,
])
}
}