Permalink
Browse files

Merge pull request #20 from gladly-team/kevin/google-gst

Add Google GST (gtag.js) to head
  • Loading branch information...
kmjennison committed Sep 25, 2018
2 parents 0937bda + c378f92 commit 2145b9eece1ac2d3507e1d53d8708c089605f2a2
Showing with 33 additions and 1 deletion.
  1. +28 −1 gatsby-ssr.js
  2. +1 −0 package.json
  3. +4 −0 yarn.lock
View
@@ -1,7 +1,34 @@
/* globals exports process */
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
// You can delete this file if you're not using it
import React from 'react'
import { oneLine } from 'common-tags'
// Google GST (gtag.js):
// https://github.com/gatsbyjs/gatsby/issues/8341
exports.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}');`,
}}
/>,
])
}
}
View
@@ -7,6 +7,7 @@
"@material-ui/icons": "^1.0.0-beta.43",
"babel-polyfill": "^6.26.0",
"browser-detect": "^0.2.26",
"common-tags": "^1.8.0",
"gatsby": "^1.9.247",
"gatsby-link": "^1.6.40",
"gatsby-plugin-facebook-pixel": "^1.0.3",
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 2145b9e

Please sign in to comment.