Skip to content

Commit

Permalink
feat(analytics): adds Google Analytics to production build
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Feb 12, 2021
1 parent fdbb0f5 commit 6a6b1fe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,22 @@ if (process.env.GATSBY_ALGOLIA_APP_ID) {
})
}

if (process.env.NODE_ENV === "production") {
const trackingId = "UA-107924368-1"
console.log(`Adding Google Analytics with ID ${trackingId}`)
console.log(`because NODE_ENV === 'production'.`)
plugins.push({
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId,
anonymize: true,
respectDNT: true,
},
})
} else {
console.log(`Skipping Google Analytics because NODE_ENV !== 'production'.`)
}

module.exports = {
siteMetadata: {
title: `St. Jude Cloud University`,
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"gatsby-image": "^2.5.0",
"gatsby-plugin-algolia": "^0.16.1",
"gatsby-plugin-catch-links": "^2.7.0",
"gatsby-plugin-google-analytics": "^2.11.0",
"gatsby-plugin-intercom-spa": "^0.2.0",
"gatsby-plugin-purgecss": "^5.0.0",
"gatsby-plugin-react-helmet": "^3.4.0",
Expand Down

1 comment on commit 6a6b1fe

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.