Skip to content

Commit da7aebb

Browse files
author
Laza Nantenaina
committed
📈 Add google analytics
1 parent 28ea625 commit da7aebb

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
.cache/
33
public
44
private-key.pem
5+
.env

‎gatsby-config.js

+33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1+
require("dotenv").config({
2+
path: ".env",
3+
});
4+
15
module.exports = {
26
plugins: [
7+
{
8+
resolve: `gatsby-plugin-google-gtag`,
9+
options: {
10+
// You can add multiple tracking ids and a pageview event will be fired for all of them.
11+
trackingIds: [
12+
process.env.GA_TRACKING_ID, // Google Analytics / GA
13+
],
14+
// This object gets passed directly to the gtag config command
15+
// This config will be shared across all trackingIds
16+
// gtagConfig: {
17+
// optimize_id: "OPT_CONTAINER_ID",
18+
// anonymize_ip: true,
19+
// cookie_expires: 0,
20+
// },
21+
// This object is used for configuration specific to this plugin
22+
pluginConfig: {
23+
// Puts tracking script in the head instead of the body
24+
head: false,
25+
// Setting this parameter is also optional
26+
respectDNT: true,
27+
// Avoids sending pageview hits from custom paths
28+
// exclude: ["/preview/**", "/do-not-track/me/too/"],
29+
// Defaults to https://www.googletagmanager.com
30+
// origin: "YOUR_SELF_HOSTED_ORIGIN",
31+
// Delays processing pageview events on route update (in milliseconds)
32+
delayOnRouteUpdate: 0,
33+
},
34+
},
35+
},
336
`gatsby-plugin-sharp`,
437
`gatsby-plugin-styled-components`,
538
`gatsby-plugin-image`,

‎package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"framer-motion": "^4.1.17",
2323
"gatsby": "^3.9.1",
2424
"gatsby-plugin-google-fonts": "^1.0.1",
25+
"gatsby-plugin-google-gtag": "^5.2.0",
2526
"gatsby-plugin-image": "^2.0.0",
2627
"gatsby-plugin-intl": "^0.3.3",
2728
"gatsby-plugin-manifest": "^4.18.1",

0 commit comments

Comments
 (0)