From ca7d688623f9c051f87a1ef8bf840797e507ccdf Mon Sep 17 00:00:00 2001 From: Vim <86254807+vim-usds@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:54:10 -0700 Subject: [PATCH] remove GA script tag and use Gatsby plugin (#756) --- client/gatsby-config.js | 40 ++++++++++++++++++++++++++++++++ client/package-lock.json | 25 ++++++++++++++++++++ client/package.json | 1 + client/src/components/layout.tsx | 5 ---- 4 files changed, 66 insertions(+), 5 deletions(-) diff --git a/client/gatsby-config.js b/client/gatsby-config.js index 931d9de6..8179aace 100644 --- a/client/gatsby-config.js +++ b/client/gatsby-config.js @@ -9,6 +9,46 @@ module.exports = { }, pathPrefix: `${process.env.PATH_PREFIX}`, plugins: [ + { + resolve: `gatsby-plugin-google-analytics`, + options: { + // The property ID; the tracking code won't be generated without it + trackingId: 'UA-33523145-1', + + // Defines where to place the tracking script - `true` in the head and `false` in the body + head: false, + + // Setting this parameter is optional + anonymize: true, + + // Setting this parameter is also optional + respectDNT: true, + + // Avoids sending pageview hits from custom paths + // exclude: ['/preview/**', '/do-not-track/me/too/'], + + // Delays sending pageview hits on route update (in milliseconds) + pageTransitionDelay: 0, + + // Enables Google Optimize using your container Id + // optimizeId: 'YOUR_GOOGLE_OPTIMIZE_TRACKING_ID', + // Enables Google Optimize Experiment ID + // experimentId: 'YOUR_GOOGLE_EXPERIMENT_ID', + // Set Variation ID. 0 for original 1,2,3.... + // variationId: 'YOUR_GOOGLE_OPTIMIZE_VARIATION_ID', + + // Defers execution of google analytics script after page load + defer: false, + + // Any additional optional fields + sampleRate: 5, + siteSpeedSampleRate: 10, + cookieDomain: 'screeningtool.geoplatform.gov', + + // defaults to false + enableWebVitalsTracking: true, + }, + }, { resolve: 'gatsby-plugin-sass', options: { diff --git a/client/package-lock.json b/client/package-lock.json index 9cd6dfba..7daef1f2 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -10815,6 +10815,26 @@ "micromatch": "^4.0.2" } }, + "gatsby-plugin-google-analytics": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/gatsby-plugin-google-analytics/-/gatsby-plugin-google-analytics-3.14.0.tgz", + "integrity": "sha512-yfSBRrGZZWruKDQMAJOHp7S1nUBQewT9MuvqegCqFsHhxUtm6PZ5JFv3k8385DfQ/+ux9MmzpY20vQ0E5/30fA==", + "requires": { + "@babel/runtime": "^7.15.4", + "minimatch": "3.0.4", + "web-vitals": "^1.1.2" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz", + "integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==", + "requires": { + "regenerator-runtime": "^0.13.4" + } + } + } + }, "gatsby-plugin-intl": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/gatsby-plugin-intl/-/gatsby-plugin-intl-0.3.3.tgz", @@ -22743,6 +22763,11 @@ "minimalistic-assert": "^1.0.0" } }, + "web-vitals": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-1.1.2.tgz", + "integrity": "sha512-PFMKIY+bRSXlMxVAQ+m2aw9c/ioUYfDgrYot0YUa+/xa0sakubWhSDyxAKwzymvXVdF4CZI71g06W+mqhzu6ig==" + }, "webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", diff --git a/client/package.json b/client/package.json index 37795144..55c35cd6 100644 --- a/client/package.json +++ b/client/package.json @@ -76,6 +76,7 @@ "@turf/bbox": "^6.5.0", "chroma-js": "^2.1.2", "d3-ease": "^3.0.1", + "gatsby-plugin-google-analytics": "^3.14.0", "mapbox-gl": "^1.13.0", "maplibre-gl": ">=1.14.0", "query-string": "^7.0.0", diff --git a/client/src/components/layout.tsx b/client/src/components/layout.tsx index 3d702203..515e844b 100644 --- a/client/src/components/layout.tsx +++ b/client/src/components/layout.tsx @@ -15,11 +15,6 @@ const Layout = ({children, location, title}: ILayoutProps) => { return ( <> -