diff --git a/app/components/Layout/Layout.js b/app/components/Layout/Layout.js
index 25f11ec8..6b213ba4 100644
--- a/app/components/Layout/Layout.js
+++ b/app/components/Layout/Layout.js
@@ -6,6 +6,7 @@ import { Helmet } from 'react-helmet';
import styled from 'styled-components';
import { observer, inject } from 'mobx-react';
import keydown from 'react-keydown';
+import Analytics from 'shared/components/Analytics';
import Flex from 'shared/components/Flex';
import { color, layout } from 'shared/styles/constants';
import { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers';
@@ -108,6 +109,7 @@ type Props = {
content="width=device-width, initial-scale=1.0"
/>
+
{this.props.ui.progressBarVisible && }
{this.props.notifications}
diff --git a/server/pages/components/Analytics.js b/server/pages/components/Analytics.js
deleted file mode 100644
index b9f085ba..00000000
--- a/server/pages/components/Analytics.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// @flow
-import React from 'react';
-
-function getScript() {
- if (!process.env.GOOGLE_ANALYTICS_ID) return undefined;
-
- return {
- __html: `
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', '${process.env.GOOGLE_ANALYTICS_ID}');
- `,
- };
-}
-
-function Analytics() {
- if (!process.env.GOOGLE_ANALYTICS_ID) return null;
-
- return (
-
-
-
-
- );
-}
-
-export default Analytics;
diff --git a/server/pages/components/Layout.js b/server/pages/components/Layout.js
index d12937b9..8b5e91a7 100644
--- a/server/pages/components/Layout.js
+++ b/server/pages/components/Layout.js
@@ -2,7 +2,7 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import Navigation from './Navigation';
-import Analytics from './Analytics';
+import Analytics from '../../../shared/components/Analytics';
import globalStyles from '../../../shared/styles/globals';
type Props = {
diff --git a/shared/components/Analytics.js b/shared/components/Analytics.js
new file mode 100644
index 00000000..0e37197c
--- /dev/null
+++ b/shared/components/Analytics.js
@@ -0,0 +1,25 @@
+// @flow
+import React from 'react';
+
+function Analytics() {
+ const id = process.env.GOOGLE_ANALYTICS_ID;
+ if (!id) return null;
+
+ return (
+
+
+
+
+ );
+}
+
+export default Analytics;
diff --git a/webpack.config.js b/webpack.config.js
index 53e855a8..33e30a30 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -14,7 +14,7 @@ const definePlugin = new webpack.DefinePlugin({
SLACK_KEY: JSON.stringify(process.env.SLACK_KEY),
BASE_URL: JSON.stringify(process.env.URL),
BUGSNAG_KEY: JSON.stringify(process.env.BUGSNAG_KEY),
- DEPLOYMENT: JSON.stringify(process.env.DEPLOYMENT || 'hosted'),
+ DEPLOYMENT: JSON.stringify(process.env.DEPLOYMENT || 'hosted')
});
module.exports = {
diff --git a/webpack.config.prod.js b/webpack.config.prod.js
index a17b872e..4a3600d8 100644
--- a/webpack.config.prod.js
+++ b/webpack.config.prod.js
@@ -38,6 +38,7 @@ productionWebpackConfig.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
+ GOOGLE_ANALYTICS_ID: JSON.stringify(process.env.GOOGLE_ANALYTICS_ID),
},
})
);