diff --git a/package.json b/package.json index b5c00b4d..b261ae9c 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "react-apollo": "^2.1.9", "react-dom": "^16.14.0", "react-ga": "^2.5.3", + "react-gtm-module": "^2.0.11", "react-helmet": "^5.2.0", "react-measure": "^2.1.0", "react-router-dom": "^5.0.1", diff --git a/public/config.template b/public/config.template index b47e95b4..dcc7652b 100644 --- a/public/config.template +++ b/public/config.template @@ -1,2 +1,3 @@ // DevOps context -var configApiUrl = DEVOPS_CONTEXT_PLATFORM_APP_CONFIG_API_URL \ No newline at end of file +var configApiUrl = DEVOPS_CONTEXT_PLATFORM_APP_CONFIG_API_URL +var configGoogleTagManagerID = DEVOPS_CONTEXT_PLATFORM_APP_CONFIG_GOOGLE_TAG_MANAGER_ID \ No newline at end of file diff --git a/public/index.html b/public/index.html index 40dfa171..f286e13d 100644 --- a/public/index.html +++ b/public/index.html @@ -1,31 +1,17 @@ - - - <% if (process.env.REACT_APP_GTMID) { %> - - - - <% } %> - - - - - - - - - Open Targets Genetics - - - - - - - - - - - - - <% if (process.env.REACT_APP_GTMID) { %> - - - - <% } %> - -
- + + + + + + + + + + +
+ - - + \ No newline at end of file diff --git a/src/config.js b/src/config.js index ecaf69e4..32bb0d36 100644 --- a/src/config.js +++ b/src/config.js @@ -1,7 +1,6 @@ const config = { - apiUrl: window.configApiUrl - ? window.configApiUrl - : 'https://genetics-api.opentargets.io/graphql', + apiUrl: window.configApiUrl ?? 'https://genetics-api.opentargets.io/graphql', + googleTagManagerID: window.configGoogleTagManagerID ?? null, }; export default config; diff --git a/src/index.js b/src/index.js index 3f53467b..df627d65 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ import { ApolloClient } from 'apollo-client'; import { ApolloProvider } from 'react-apollo'; import { InMemoryCache } from 'apollo-cache-inmemory'; import { HttpLink } from 'apollo-link-http'; +import TagManager from 'react-gtm-module'; import App from './App'; import { unregister } from './registerServiceWorker'; @@ -20,6 +21,10 @@ const client = new ApolloClient({ cache: new InMemoryCache(), }); +if (config.googleTagManagerID) { + TagManager.initialize({ gtmId: config.googleTagManagerID }); +} + ReactDOM.render( diff --git a/yarn.lock b/yarn.lock index e3be1f80..7d607dc5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11232,6 +11232,11 @@ react-ga@^2.5.3: prop-types "^15.6.0" react "^15.6.2 || ^16.0" +react-gtm-module@^2.0.11: + version "2.0.11" + resolved "https://registry.yarnpkg.com/react-gtm-module/-/react-gtm-module-2.0.11.tgz#14484dac8257acd93614e347c32da9c5ac524206" + integrity sha512-8gyj4TTxeP7eEyc2QKawEuQoAZdjKvMY4pgWfycGmqGByhs17fR+zEBs0JUDq4US/l+vbTl+6zvUIx27iDo/Vw== + react-helmet@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7"