gatsby-plugin-google-gtag 5.8.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.8.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@5.8.0/packages/gatsby-plugin-google-gtag) (2023-03-21)
7
+
8
+ [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v5.8)
9
+
10
+ **Note:** Version bump only for package gatsby-plugin-google-gtag
11
+
6
12
  ## [5.7.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@5.7.0/packages/gatsby-plugin-google-gtag) (2023-02-21)
7
13
 
8
14
  [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v5.7)
package/README.md CHANGED
@@ -10,7 +10,7 @@ For more general information on gtag you can read Google's official documentatio
10
10
 
11
11
  If you're migrating from analytics.js (gatsby-plugin-google-analytics) you can read about the subtle API differences in more depth at: https://developers.google.com/analytics/devguides/migration/ua/analyticsjs-to-gtagjs.
12
12
 
13
- **Please note:** This plugin only works in production mode! To test your Global Site Tag is installed and firing events correctly run: `gatsby build && gatsby serve.`
13
+ **Please note:** This plugin only works in production mode! To test that your Global Site Tag is installed and firing events correctly run: `gatsby build && gatsby serve.`
14
14
 
15
15
  ## Install
16
16
 
@@ -20,8 +20,9 @@ npm install gatsby-plugin-google-gtag
20
20
 
21
21
  ## How to use
22
22
 
23
- ```js
24
- // In your gatsby-config.js
23
+ The `trackingIds` option is **required** for this plugin to work correctly.
24
+
25
+ ```js:title=gatsby-config.js
25
26
  module.exports = {
26
27
  plugins: [
27
28
  {
@@ -59,6 +60,50 @@ module.exports = {
59
60
  }
60
61
  ```
61
62
 
63
+ ### `gtagConfig.anonymize_ip` option
64
+
65
+ Some countries (such as Germany) require you to use the
66
+ [\_anonymizeIP](https://support.google.com/analytics/answer/2763052) function for
67
+ Google Site Tag. Otherwise you are not allowed to use it. The option adds the
68
+ block of code below:
69
+
70
+ ```js
71
+ function gaOptout() {
72
+ ;(document.cookie =
73
+ disableStr + "=true; expires=Thu, 31 Dec 2099 23:59:59 UTC;path=/"),
74
+ (window[disableStr] = !0)
75
+ }
76
+
77
+ var gaProperty = "UA-XXXXXXXX-X",
78
+ disableStr = "ga-disable-" + gaProperty
79
+ document.cookie.indexOf(disableStr + "=true") > -1 && (window[disableStr] = !0)
80
+ ```
81
+
82
+ If your visitors should be able to set an Opt-Out-Cookie (No future tracking)
83
+ you can set a link e.g. in your imprint as follows:
84
+
85
+ `<a href="javascript:gaOptout();">Deactivate Google Tracking</a>`
86
+
87
+ ### `gtagConfig.optimize_id` option
88
+
89
+ If you need to use Google Optimize for A/B testing, you can add this optional Optimize container id to allow Google Optimize to load the correct test parameters for your site.
90
+
91
+ ### Other `gtagConfig` options
92
+
93
+ The `gtagConfig` is passed directly to the gtag config command, so you can specify everything it supports, e.g. `gtagConfig.cookie_name`, `gtagConfig.sample_rate`. If you're migrating from the analytics.js plugin, this means that all Create Only Fields should be snake_cased.
94
+
95
+ ### `pluginConfig.respectDNT` option
96
+
97
+ If you enable this optional option, Google Global Site Tag will not be loaded at all for visitors that have "Do Not Track" enabled. While using Google Global Site Tag does not necessarily constitute Tracking, you might still want to do this to cater to more privacy oriented users.
98
+
99
+ ### `pluginConfig.exclude` option
100
+
101
+ If you need to exclude any path from the tracking system, you can add it (one or more) to this optional array as glob expressions.
102
+
103
+ ### `pluginConfig.delayOnRouteUpdate` option
104
+
105
+ If you need to delay processing pageview events on route update (e.g. to wait for page transitions with [`gatsby-plugin-transition-link`](https://www.gatsbyjs.com/plugins/gatsby-plugin-transition-link/)), then this option adds a delay before generating the pageview event.
106
+
62
107
  ## Custom Events
63
108
 
64
109
  This plugin automatically sends a "pageview" event to all products given as "trackingIds" on every Gatsbys route change.
@@ -99,47 +144,3 @@ export default () => (
99
144
  </div>
100
145
  )
101
146
  ```
102
-
103
- ## The "gtagConfig.anonymize_ip" option
104
-
105
- Some countries (such as Germany) require you to use the
106
- [\_anonymizeIP](https://support.google.com/analytics/answer/2763052) function for
107
- Google Site Tag. Otherwise you are not allowed to use it. The option adds the
108
- block of code below:
109
-
110
- ```js
111
- function gaOptout() {
112
- ;(document.cookie =
113
- disableStr + "=true; expires=Thu, 31 Dec 2099 23:59:59 UTC;path=/"),
114
- (window[disableStr] = !0)
115
- }
116
-
117
- var gaProperty = "UA-XXXXXXXX-X",
118
- disableStr = "ga-disable-" + gaProperty
119
- document.cookie.indexOf(disableStr + "=true") > -1 && (window[disableStr] = !0)
120
- ```
121
-
122
- If your visitors should be able to set an Opt-Out-Cookie (No future tracking)
123
- you can set a link e.g. in your imprint as follows:
124
-
125
- `<a href="javascript:gaOptout();">Deactivate Google Tracking</a>`
126
-
127
- ## The "gtagConfig.optimize_id" option
128
-
129
- If you need to use Google Optimize for A/B testing, you can add this optional Optimize container id to allow Google Optimize to load the correct test parameters for your site.
130
-
131
- ## Other "gtagConfig" options
132
-
133
- The `gtagConfig` is passed directly to the gtag config command, so you can specify everything it supports, e.g. `gtagConfig.cookie_name`, `gtagConfig.sample_rate`. If you're migrating from the analytics.js plugin, this means that all Create Only Fields should be snake_cased.
134
-
135
- ## The "pluginConfig.respectDNT" option
136
-
137
- If you enable this optional option, Google Global Site Tag will not be loaded at all for visitors that have "Do Not Track" enabled. While using Google Global Site Tag does not necessarily constitute Tracking, you might still want to do this to cater to more privacy oriented users.
138
-
139
- ## The "pluginConfig.exclude" option
140
-
141
- If you need to exclude any path from the tracking system, you can add it (one or more) to this optional array as glob expressions.
142
-
143
- ## The "pluginConfig.delayOnRouteUpdate" option
144
-
145
- If you need to delay processing pageview events on route update (e.g. to wait for page transitions with [`gatsby-plugin-transition-link`](https://www.gatsbyjs.com/plugins/gatsby-plugin-transition-link/)), then this option adds a delay before generating the pageview event.
package/gatsby-node.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ // @ts-check
4
+
5
+ /**
6
+ * @type {import('gatsby').GatsbyNode["pluginOptionsSchema"]}
7
+ */
8
+ exports.pluginOptionsSchema = function (_ref) {
9
+ var Joi = _ref.Joi;
10
+ return Joi.object({
11
+ trackingIds: Joi.array().items(Joi.string()).description("The tracking IDs; the tracking code won't be generated without them.").required(),
12
+ gtagConfig: Joi.object().keys({
13
+ optimize_id: Joi.string().description("Enable if you need to use Google Optimize."),
14
+ anonymize_ip: Joi.boolean().description("Enable if you need to use the \"anonymizeIP\" function.").default(false)
15
+ }).unknown(true).description("This object gets passed directly to the gtag config command.").default({}),
16
+ pluginConfig: Joi.object().keys({
17
+ head: Joi.boolean().description("Puts tracking script in the <head> instead of the <body>").default(false),
18
+ respectDNT: Joi.boolean().description("If you enable this optional option, Google Global Site Tag will not be loaded at all for visitors that have \"Do Not Track\" enabled.").default(false),
19
+ exclude: Joi.array().items(Joi.string()).description("If you need to exclude any path from the tracking system, you can add it (one or more) to this optional array as glob expressions.").default([]),
20
+ origin: Joi.string().description("Your optional self hosted origin for the script.").default("https://www.googletagmanager.com"),
21
+ delayOnRouteUpdate: Joi.number().description("Delay processing pageview events on route update").default(0)
22
+ }).description("Configure the plugin's behavior.")
23
+ });
24
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-plugin-google-gtag",
3
3
  "description": "Gatsby plugin to add google gtag onto a site",
4
- "version": "5.8.0",
4
+ "version": "5.9.0",
5
5
  "author": "Tyler Buchea <tyler@buchea.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -13,8 +13,9 @@
13
13
  "devDependencies": {
14
14
  "@babel/cli": "^7.20.7",
15
15
  "@babel/core": "^7.20.12",
16
- "babel-preset-gatsby-package": "^3.8.0",
17
- "cross-env": "^7.0.3"
16
+ "babel-preset-gatsby-package": "^3.9.0",
17
+ "cross-env": "^7.0.3",
18
+ "gatsby-plugin-utils": "^4.9.0"
18
19
  },
19
20
  "homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-google-gtag#readme",
20
21
  "keywords": [
@@ -43,5 +44,5 @@
43
44
  "engines": {
44
45
  "node": ">=18.0.0"
45
46
  },
46
- "gitHead": "b1abb5bc91abdf3f966c8920c9c1fd757b8c5831"
47
+ "gitHead": "e95b10ae0d7c6f01b627217333eb9a630f16e546"
47
48
  }