Skip to content

Commit

Permalink
feat: gtm setup (#5268)
Browse files Browse the repository at this point in the history
  • Loading branch information
yathomasi authored Jun 27, 2024
1 parent 91e2571 commit 8882a0b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ const plugins = [
}
]

if (process.env.GATSBY_GTM_ID) {
plugins.push({
resolve: `gatsby-plugin-google-tagmanager`,
options: {
id: process.env.GATSBY_GTM_ID,

// Include GTM in development.
//
// Defaults to false meaning GTM will only be loaded in production.
includeInDevelopment: process.env.GTM_INCLUDE_IN_DEV === `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` }
}
})
}

if (process.env.ANALYZE) {
plugins.push({
resolve: 'gatsby-plugin-webpack-bundle-analyser-v2'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"dotenv": "16.4.5",
"gatsby": "5.13.6",
"gatsby-plugin-catch-links": "5.13.1",
"gatsby-plugin-google-tagmanager": "5.13.1",
"gatsby-plugin-image": "3.13.1",
"gatsby-plugin-manifest": "5.13.1",
"gatsby-plugin-postcss": "6.13.1",
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12638,6 +12638,20 @@ __metadata:
languageName: node
linkType: hard

"gatsby-plugin-google-tagmanager@npm:5.13.1":
version: 5.13.1
resolution: "gatsby-plugin-google-tagmanager@npm:5.13.1"
dependencies:
"@babel/runtime": "npm:^7.20.13"
web-vitals: "npm:^1.1.2"
peerDependencies:
gatsby: ^5.0.0-next
react: ^18.0.0 || ^0.0.0
react-dom: ^18.0.0 || ^0.0.0
checksum: 10c0/f375ab868ff5c8acd32024b852bee6f3dc3a0b0849a9d67dad78efdfa55be12a60b7613aa49f51a796a41877ace36b3e6a92eae3295073fd12326857da36d78d
languageName: node
linkType: hard

"gatsby-plugin-image@npm:3.13.1, gatsby-plugin-image@npm:^3.13.1":
version: 3.13.1
resolution: "gatsby-plugin-image@npm:3.13.1"
Expand Down Expand Up @@ -24991,6 +25005,13 @@ __metadata:
languageName: node
linkType: hard

"web-vitals@npm:^1.1.2":
version: 1.1.2
resolution: "web-vitals@npm:1.1.2"
checksum: 10c0/9521ea2e8ca2e4446ba8e3d5430b0c9a9a07e0d6f468a90dc5fab2bab524fb1a699f3874ea392c9e35a63dcf3651b40130d58ebd78e53a406cb9622049bf1403
languageName: node
linkType: hard

"webidl-conversions@npm:^3.0.0":
version: 3.0.1
resolution: "webidl-conversions@npm:3.0.1"
Expand Down Expand Up @@ -25158,6 +25179,7 @@ __metadata:
eslint-plugin-react: "npm:7.34.3"
gatsby: "npm:5.13.6"
gatsby-plugin-catch-links: "npm:5.13.1"
gatsby-plugin-google-tagmanager: "npm:5.13.1"
gatsby-plugin-image: "npm:3.13.1"
gatsby-plugin-manifest: "npm:5.13.1"
gatsby-plugin-postcss: "npm:6.13.1"
Expand Down

0 comments on commit 8882a0b

Please sign in to comment.