Skip to content

Commit

Permalink
Restore: old implementation of google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
rdig committed Sep 2, 2021
1 parent 31201ca commit af3a0ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 43 deletions.
30 changes: 1 addition & 29 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,34 +150,6 @@ module.exports = {
alias: utils.getModuleAliases(),
extensions: [],
},
},
{
resolve: "gatsby-plugin-google-tagmanager",
options: {
id: process.env.GOOGLE_ANALYTICS_TRACKING_ID,

// Include GTM in development.
//
// Defaults to false meaning GTM will only be loaded in production.
includeInDevelopment: true,

// datalayer to be set before GTM is loaded
// should be an object or a function that is executed in the browser
//
// Defaults to null
defaultDataLayer: { platform: "gatsby" },

// Specify optional GTM environment details.
// gtmAuth: "YOUR_GOOGLE_TAGMANAGER_ENVIRONMENT_AUTH_STRING",
// gtmPreview: "YOUR_GOOGLE_TAGMANAGER_ENVIRONMENT_PREVIEW_NAME",
dataLayerName: "dataLayer",

// Name of the event that is triggered
// on every Gatsby route change.
//
// Defaults to gatsby-route-change
// routeChangeEventName: "YOUR_ROUTE_CHANGE_EVENT_NAME",
},
},
}
],
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"docsearch.js": "^2.6.2",
"formik": "^1.5.8",
"gatsby": "^2.2.5",
"gatsby-plugin-google-tagmanager": "^3.5.0",
"gatsby-plugin-i18n": "^1.0.1",
"nanoid": "^2.0.1",
"prism-themes": "^1.0.0",
Expand Down
26 changes: 13 additions & 13 deletions src/modules/layouts/components/GlobalLayout/GlobalLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ const GlobalLayout = ({ children, location }: Props) => {
href={withPrefix('/img/favicon.ico')}
/>
<script src={withPrefix('/js/fontloader.js')} />
<script
async
/* eslint-disable-next-line max-len */
src={`https://www.googletagmanager.com/gtag/js?id=${GoogleTagManagerId}`}
/>
<script>
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GoogleTagManagerId}');
`}
</script>
</Helmet>
<FileContext.Provider value={getFileMapping(data.files.edges)}>
<noscript>
<iframe
title="googletagmanager"
// eslint-disable-next-line max-len
src={`https://www.googletagmanager.com/ns.html?id=${GoogleTagManagerId}`}
height="0"
width="0"
style={{
display: 'none',
visibility: 'hidden',
}}
/>
</noscript>
<IntlProvider
locale={locale}
defaultLocale={DEFAULT_LOCALE}
Expand Down

0 comments on commit af3a0ce

Please sign in to comment.