Skip to content

Commit

Permalink
Change plugin for GA, add info to readme to add new env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
veto221 committed Apr 26, 2022
1 parent b7505dd commit 354f561
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This project works on node ^14.17.0 || >=16.0.0, we do not support node 15.
```
GATSBY_FLOTIQ_API_KEY=YOUR FLOTIQ API KEY
GA_TRACKING_ID=YOUR GA TRACKING KEY
GA_MEASUREMENT_ID=YOUR MEASUREMENT ID
```

4. **Start developing.**
Expand Down
31 changes: 17 additions & 14 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ module.exports = {
},
plugins: [
{
resolve: 'gatsby-plugin-google-analytics',
// How to configure? https://www.gatsbyjs.com/plugins/gatsby-plugin-google-gtag/
// Video: https://www.youtube.com/watch?v=Dwi99jtl3Fs
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingId: process.env.GA_TRACKING_ID || 'test',
// Puts tracking script in the head instead of the body
head: true,
// IP anonymization for GDPR compliance
anonymize: true,
// Disable analytics for users with `Do Not Track` enabled
respectDNT: true,
// Avoids sending pageview hits from custom paths
exclude: ['/preview/**'],
// Specifies what percentage of users should be tracked
sampleRate: 100,
// Determines how often site speed tracking beacons will be sent
siteSpeedSampleRate: 10,
trackingIds: [
process.env.GA_TRACKING_ID || 'test', // Google Analytics / GA
process.env.GA_MEASUREMENT_ID || 'test', // GA Measurement
],
gtagConfig: {
optimize_id: 'OPT_CONTAINER_ID',
anonymize_ip: true,
cookie_expires: 0,
},
pluginConfig: {
head: true,
respectDNT: true,
exclude: ['/preview/**', '/do-not-track/me/too/'],
},
},
},
'gatsby-plugin-react-helmet',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@tailwindcss/line-clamp": "^0.3.1",
"flotiq-components-react": "^0.5.0",
"gatsby": "^4.7.2",
"gatsby-plugin-google-analytics": "^4.7.0",
"gatsby-plugin-google-gtag": "^4.12.1",
"gatsby-plugin-image": "^2.7.0",
"gatsby-plugin-manifest": "^4.7.0",
"gatsby-plugin-react-helmet": "^5.7.0",
Expand Down
18 changes: 6 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5397,14 +5397,13 @@ gatsby-page-utils@^2.7.0:
lodash "^4.17.21"
micromatch "^4.0.4"

gatsby-plugin-google-analytics@^4.7.0:
version "4.7.0"
resolved "https://registry.npmjs.org/gatsby-plugin-google-analytics/-/gatsby-plugin-google-analytics-4.7.0.tgz"
integrity sha512-LQN+Awf7WvodYKytBZFLL40B3PPk7TPHjPa7fDzlq7J9k+/MIXQ1aYAmxhVJN3WK//GdhrltrxPZVwgomaO5NA==
gatsby-plugin-google-gtag@^4.12.1:
version "4.12.1"
resolved "https://registry.yarnpkg.com/gatsby-plugin-google-gtag/-/gatsby-plugin-google-gtag-4.12.1.tgz#2e9ffa3aca3a5df26a95408e4ed5898003bfd089"
integrity sha512-dYf5zC+FPekohgXMnJYTkjz9J/IC3R3eHR6xjgLCEsMUxw7s0AApZxq7IUyCTTioGvLi3k/NPS9sBob7/60n9Q==
dependencies:
"@babel/runtime" "^7.15.4"
minimatch "3.0.4"
web-vitals "^1.1.2"
minimatch "^3.1.2"

gatsby-plugin-image@^2.7.0:
version "2.7.0"
Expand Down Expand Up @@ -7512,7 +7511,7 @@ minimatch@3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimatch@^3.0.4:
minimatch@^3.0.4, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
Expand Down Expand Up @@ -10622,11 +10621,6 @@ weak-lru-cache@^1.0.0:
resolved "https://registry.npmjs.org/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz"
integrity sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw==

web-vitals@^1.1.2:
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@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
Expand Down

0 comments on commit 354f561

Please sign in to comment.