diff --git a/public/googleTagManager.js b/public/googleTagManager.js
new file mode 100644
index 00000000..9e7a5e4f
--- /dev/null
+++ b/public/googleTagManager.js
@@ -0,0 +1,3 @@
+export const gtmScript = "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-NT29XCN');";
+
+export const gtmNoscript = '';
diff --git a/public/index.jsx b/public/index.jsx
index eca1d092..b1f2d9e4 100644
--- a/public/index.jsx
+++ b/public/index.jsx
@@ -1,12 +1,17 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
+import { gtmScript } from './googleTagManager';
+
export default function renderHtml(data, body) {
return `
${ReactDOMServer.renderToStaticMarkup(
+ {(process.env.NODE_ENV === 'production') &&
+
+ }
Patrick Hooper
diff --git a/src/app/Root.jsx b/src/app/Root.jsx
index d05bb5af..19341604 100644
--- a/src/app/Root.jsx
+++ b/src/app/Root.jsx
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
+import { BrowserRouter } from 'react-router-dom';
import './global.css';
import Content from './layout/Content.jsx';
@@ -17,7 +18,7 @@ export default function Root({ HtmlTag, Router, routerProps }) {
}
Root.propTypes = {
- HtmlTag: PropTypes.string.isRequired,
+ HtmlTag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]).isRequired,
Router: PropTypes.func.isRequired,
routerProps: PropTypes.shape({
location: PropTypes.string,
@@ -25,5 +26,7 @@ Root.propTypes = {
};
Root.defaultProps = {
+ HtmlTag: 'div',
+ Router: BrowserRouter,
routerProps: {},
};
diff --git a/src/dev.jsx b/src/dev.jsx
index 9a343a0d..4f1a636f 100644
--- a/src/dev.jsx
+++ b/src/dev.jsx
@@ -2,7 +2,6 @@ import 'normalize.css';
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
-import { BrowserRouter } from 'react-router-dom';
import Root from './app/Root.jsx';
@@ -11,7 +10,7 @@ delete AppContainer.prototype.unstable_handleError;
function render(Component) {
ReactDOM.render(
-
+
,
document.getElementById('app'),
);
diff --git a/src/static.jsx b/src/static.jsx
index 0337996b..31b8962c 100644
--- a/src/static.jsx
+++ b/src/static.jsx
@@ -1,13 +1,28 @@
import 'normalize.css';
+import PropTypes from 'prop-types';
import React from 'react';
import { StaticRouter } from 'react-router-dom';
+import { gtmNoscript } from '../public/googleTagManager';
import renderHtml from '../public/index.jsx';
import Root from './app/Root.jsx';
+function Body({ children }) {
+ return (
+
+
+ {children}
+
+ );
+}
+
+Body.propTypes = {
+ children: PropTypes.node.isRequired,
+};
+
export default function render({ path: location, webpackStats }) {
return renderHtml(
webpackStats,
- ,
+ ,
);
}