@segment/analytics-browser-actions-google-analytics-4 1.0.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.
Files changed (64) hide show
  1. package/package.json +20 -0
  2. package/src/__tests__/addPaymentInfo.test.ts +101 -0
  3. package/src/__tests__/addToCart.test.ts +95 -0
  4. package/src/__tests__/addToWishlist.test.ts +95 -0
  5. package/src/__tests__/beginCheckout.test.ts +101 -0
  6. package/src/__tests__/customEvent.test.ts +70 -0
  7. package/src/__tests__/generateLead.test.ts +68 -0
  8. package/src/__tests__/login.test.ts +63 -0
  9. package/src/__tests__/purchase.test.ts +103 -0
  10. package/src/__tests__/refund.test.ts +103 -0
  11. package/src/__tests__/removeFromCart.test.ts +99 -0
  12. package/src/__tests__/search.test.ts +64 -0
  13. package/src/__tests__/selectItem.test.ts +96 -0
  14. package/src/__tests__/selectPromotion.test.ts +111 -0
  15. package/src/__tests__/signUp.test.ts +62 -0
  16. package/src/__tests__/viewCart.test.ts +96 -0
  17. package/src/__tests__/viewItem.test.ts +96 -0
  18. package/src/__tests__/viewItemList.test.ts +96 -0
  19. package/src/__tests__/viewPromotion.test.ts +111 -0
  20. package/src/addPaymentInfo/generated-types.ts +117 -0
  21. package/src/addPaymentInfo/index.ts +48 -0
  22. package/src/addToCart/generated-types.ts +109 -0
  23. package/src/addToCart/index.ts +36 -0
  24. package/src/addToWishlist/generated-types.ts +109 -0
  25. package/src/addToWishlist/index.ts +38 -0
  26. package/src/beginCheckout/generated-types.ts +113 -0
  27. package/src/beginCheckout/index.ts +38 -0
  28. package/src/customEvent/generated-types.ts +28 -0
  29. package/src/customEvent/index.ts +52 -0
  30. package/src/ga4-functions.ts +8 -0
  31. package/src/ga4-properties.ts +368 -0
  32. package/src/ga4-types.ts +28 -0
  33. package/src/generateLead/generated-types.ts +28 -0
  34. package/src/generateLead/index.ts +32 -0
  35. package/src/generated-types.ts +56 -0
  36. package/src/index.ts +194 -0
  37. package/src/login/generated-types.ts +24 -0
  38. package/src/login/index.ts +31 -0
  39. package/src/purchase/generated-types.ts +125 -0
  40. package/src/purchase/index.ts +54 -0
  41. package/src/refund/generated-types.ts +129 -0
  42. package/src/refund/index.ts +57 -0
  43. package/src/removeFromCart/generated-types.ts +109 -0
  44. package/src/removeFromCart/index.ts +37 -0
  45. package/src/search/generated-types.ts +24 -0
  46. package/src/search/index.ts +30 -0
  47. package/src/selectItem/generated-types.ts +109 -0
  48. package/src/selectItem/index.ts +43 -0
  49. package/src/selectPromotion/generated-types.ts +137 -0
  50. package/src/selectPromotion/index.ts +67 -0
  51. package/src/setConfigurationFields/generated-types.ts +70 -0
  52. package/src/setConfigurationFields/index.ts +143 -0
  53. package/src/signUp/generated-types.ts +24 -0
  54. package/src/signUp/index.ts +29 -0
  55. package/src/types.ts +3 -0
  56. package/src/viewCart/generated-types.ts +109 -0
  57. package/src/viewCart/index.ts +36 -0
  58. package/src/viewItem/generated-types.ts +109 -0
  59. package/src/viewItem/index.ts +37 -0
  60. package/src/viewItemList/generated-types.ts +109 -0
  61. package/src/viewItemList/index.ts +36 -0
  62. package/src/viewPromotion/generated-types.ts +137 -0
  63. package/src/viewPromotion/index.ts +67 -0
  64. package/tsconfig.json +9 -0
package/src/index.ts ADDED
@@ -0,0 +1,194 @@
1
+ import type { Settings } from './generated-types'
2
+ import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types'
3
+ import { browserDestination } from '@segment/browser-destination-runtime/shim'
4
+
5
+ import addPaymentInfo from './addPaymentInfo'
6
+ import addToCart from './addToCart'
7
+ import addToWishlist from './addToWishlist'
8
+ import beginCheckout from './beginCheckout'
9
+ import customEvent from './customEvent'
10
+ import login from './login'
11
+ import generateLead from './generateLead'
12
+ import purchase from './purchase'
13
+ import refund from './refund'
14
+ import removeFromCart from './removeFromCart'
15
+ import search from './search'
16
+ import selectItem from './selectItem'
17
+ import selectPromotion from './selectPromotion'
18
+ import signUp from './signUp'
19
+ import viewCart from './viewCart'
20
+ import viewItem from './viewItem'
21
+ import viewItemList from './viewItemList'
22
+ import viewPromotion from './viewPromotion'
23
+ import setConfigurationFields from './setConfigurationFields'
24
+ import { defaultValues, DestinationDefinition } from '@segment/actions-core'
25
+
26
+ declare global {
27
+ interface Window {
28
+ gtag: Function
29
+ dataLayer: any
30
+ }
31
+ }
32
+
33
+ const presets: DestinationDefinition['presets'] = [
34
+ {
35
+ name: `Set Configuration Fields`,
36
+ subscribe: 'type = "page" or type = "identify"',
37
+ partnerAction: 'setConfigurationFields',
38
+ mapping: defaultValues(setConfigurationFields.fields)
39
+ }
40
+ ]
41
+
42
+ export const destination: BrowserDestinationDefinition<Settings, Function> = {
43
+ name: 'Google Analytics 4 Web',
44
+ slug: 'actions-google-analytics-4-web',
45
+ mode: 'device',
46
+
47
+ settings: {
48
+ measurementID: {
49
+ description:
50
+ 'The measurement ID associated with the web stream. Found in the Google Analytics UI under: Admin > Data Streams > Web > Measurement ID.',
51
+ label: 'Measurement ID',
52
+ type: 'string',
53
+ required: true
54
+ },
55
+ allowGoogleSignals: {
56
+ description: 'Set to false to disable all advertising features. Set to true by default.',
57
+ label: 'Allow Google Signals',
58
+ type: 'boolean',
59
+ default: true
60
+ },
61
+ allowAdPersonalizationSignals: {
62
+ description: 'Set to false to disable all advertising features. Set to true by default.',
63
+ label: 'Allow Ad Personalization Signals',
64
+ type: 'boolean',
65
+ default: true
66
+ },
67
+ cookieDomain: {
68
+ description: 'Specifies the domain used to store the analytics cookie. Set to “auto” by default.',
69
+ label: 'Cookie Domain',
70
+ type: 'string',
71
+ default: 'auto'
72
+ },
73
+ cookieExpirationInSeconds: {
74
+ description: `Every time a hit is sent to GA4, the analytics cookie expiration time is updated to be the current time plus the value of this field. The default value is two years (63072000 seconds). Please input the expiration value in seconds. More information in [Google Documentation](https://developers.google.com/analytics/devguides/collection/ga4/reference/config#)`,
75
+ label: 'Cookie Expiration In Seconds',
76
+ type: 'number',
77
+ default: 63072000
78
+ },
79
+ cookieFlags: {
80
+ description: `Appends additional flags to the analytics cookie. See [write a new cookie](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie) for some examples of flags to set.`,
81
+ label: 'Cookie Flag',
82
+ type: 'string',
83
+ multiple: true
84
+ },
85
+ cookiePath: {
86
+ description: `Specifies the subpath used to store the analytics cookie.`,
87
+ label: 'Cookie Path',
88
+ type: 'string',
89
+ multiple: true
90
+ },
91
+ cookiePrefix: {
92
+ description: `Specifies a prefix to prepend to the analytics cookie name.`,
93
+ label: 'Cookie Prefix',
94
+ type: 'string',
95
+ multiple: true
96
+ },
97
+ cookieUpdate: {
98
+ description: `Set to false to not update cookies on each page load. This has the effect of cookie expiration being relative to the first time a user visited. Set to true by default so update cookies on each page load.`,
99
+ label: 'Cookie Update',
100
+ type: 'boolean',
101
+ default: true
102
+ },
103
+ enableConsentMode: {
104
+ description: `Set to true to enable Google’s [Consent Mode](https://support.google.com/analytics/answer/9976101?hl=en). Set to false by default.`,
105
+ label: 'Enable Consent Mode',
106
+ type: 'boolean',
107
+ default: false
108
+ },
109
+ defaultAdsStorageConsentState: {
110
+ description:
111
+ 'The default value for ad cookies consent state. This is only used if Enable Consent Mode is on. Set to “granted” if it is not explicitly set. Consent state can be updated for each user in the Set Configuration Fields action.',
112
+ label: 'Default Ads Storage Consent State',
113
+ type: 'string',
114
+ choices: [
115
+ { label: 'Granted', value: 'granted' },
116
+ { label: 'Denied', value: 'denied' }
117
+ ],
118
+ default: 'granted'
119
+ },
120
+ defaultAnalyticsStorageConsentState: {
121
+ description:
122
+ 'The default value for analytics cookies consent state. This is only used if Enable Consent Mode is on. Set to “granted” if it is not explicitly set. Consent state can be updated for each user in the Set Configuration Fields action.',
123
+ label: 'Default Analytics Storage Consent State',
124
+ type: 'string',
125
+ choices: [
126
+ { label: 'Granted', value: 'granted' },
127
+ { label: 'Denied', value: 'denied' }
128
+ ],
129
+ default: 'granted'
130
+ },
131
+ waitTimeToUpdateConsentStage: {
132
+ description:
133
+ 'If your CMP loads asynchronously, it might not always run before the Google tag. To handle such situations, specify a millisecond value to control how long to wait before the consent state update is sent. Please input the wait_for_update in milliseconds.',
134
+ label: 'Wait Time to Update Consent State',
135
+ type: 'number'
136
+ }
137
+ },
138
+
139
+ initialize: async ({ settings }, deps) => {
140
+ const config = {
141
+ send_page_view: false,
142
+ cookie_update: settings.cookieUpdate,
143
+ cookie_domain: settings.cookieDomain,
144
+ cookie_prefix: settings.cookiePrefix,
145
+ cookie_expires: settings.cookieExpirationInSeconds,
146
+ cookie_path: settings.cookiePath,
147
+ allow_ad_personalization_signals: settings.allowAdPersonalizationSignals,
148
+ allow_google_signals: settings.allowGoogleSignals
149
+ }
150
+
151
+ window.dataLayer = window.dataLayer || []
152
+ window.gtag = function () {
153
+ // eslint-disable-next-line prefer-rest-params
154
+ window.dataLayer.push(arguments)
155
+ }
156
+
157
+ window.gtag('js', new Date())
158
+ window.gtag('config', settings.measurementID, config)
159
+ if (settings.enableConsentMode) {
160
+ window.gtag('consent', 'default', {
161
+ ad_storage: settings.defaultAdsStorageConsentState,
162
+ analytics_storage: settings.defaultAnalyticsStorageConsentState,
163
+ wait_for_update: settings.waitTimeToUpdateConsentStage
164
+ })
165
+ }
166
+ const script = `https://www.googletagmanager.com/gtag/js?id=${settings.measurementID}`
167
+ await deps.loadScript(script)
168
+ return window.gtag
169
+ },
170
+ presets,
171
+ actions: {
172
+ addPaymentInfo,
173
+ login,
174
+ signUp,
175
+ search,
176
+ addToCart,
177
+ addToWishlist,
178
+ removeFromCart,
179
+ selectItem,
180
+ selectPromotion,
181
+ viewItem,
182
+ viewPromotion,
183
+ beginCheckout,
184
+ purchase,
185
+ refund,
186
+ viewCart,
187
+ viewItemList,
188
+ generateLead,
189
+ customEvent,
190
+ setConfigurationFields
191
+ }
192
+ }
193
+
194
+ export default browserDestination(destination)
@@ -0,0 +1,24 @@
1
+ // Generated file. DO NOT MODIFY IT BY HAND.
2
+
3
+ export interface Payload {
4
+ /**
5
+ * A unique identifier for a user. See Google's [User-ID for cross-platform analysis](https://support.google.com/analytics/answer/9213390) and [Reporting: deduplicate user counts](https://support.google.com/analytics/answer/9355949?hl=en) documentation for more information on this identifier.
6
+ */
7
+ user_id?: string
8
+ /**
9
+ * The method used to login.
10
+ */
11
+ method?: string
12
+ /**
13
+ * The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s [Custom user properties](https://support.google.com/analytics/answer/9269570) to learn how to set and register user properties.
14
+ */
15
+ user_properties?: {
16
+ [k: string]: unknown
17
+ }
18
+ /**
19
+ * The event parameters to send to Google Analytics 4.
20
+ */
21
+ params?: {
22
+ [k: string]: unknown
23
+ }
24
+ }
@@ -0,0 +1,31 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types'
2
+ import type { Settings } from '../generated-types'
3
+ import type { Payload } from './generated-types'
4
+
5
+ import { user_properties, params, user_id, method } from '../ga4-properties'
6
+ import { updateUser } from '../ga4-functions'
7
+
8
+ // Change from unknown to the partner SDK types
9
+ const action: BrowserActionDefinition<Settings, Function, Payload> = {
10
+ title: 'Login',
11
+ description: 'Send event when a user logs in',
12
+ platform: 'web',
13
+ defaultSubscription: 'type = "track" and event = "Signed In"',
14
+ fields: {
15
+ user_id: user_id,
16
+ method: method,
17
+ user_properties: user_properties,
18
+ params: params
19
+ },
20
+
21
+ perform: (gtag, { payload }) => {
22
+ updateUser(payload.user_id, payload.user_properties, gtag)
23
+
24
+ gtag('event', 'login', {
25
+ method: payload.method,
26
+ ...payload.params
27
+ })
28
+ }
29
+ }
30
+
31
+ export default action
@@ -0,0 +1,125 @@
1
+ // Generated file. DO NOT MODIFY IT BY HAND.
2
+
3
+ export interface Payload {
4
+ /**
5
+ * A unique identifier for a user. See Google's [User-ID for cross-platform analysis](https://support.google.com/analytics/answer/9213390) and [Reporting: deduplicate user counts](https://support.google.com/analytics/answer/9355949?hl=en) documentation for more information on this identifier.
6
+ */
7
+ user_id?: string
8
+ /**
9
+ * Coupon code used for a purchase.
10
+ */
11
+ coupon?: string
12
+ /**
13
+ * Currency of the items associated with the event, in 3-letter ISO 4217 format.
14
+ */
15
+ currency: string
16
+ /**
17
+ * The list of products purchased.
18
+ */
19
+ items: {
20
+ /**
21
+ * Identifier for the product being purchased.
22
+ */
23
+ item_id?: string
24
+ /**
25
+ * Name of the product being purchased.
26
+ */
27
+ item_name?: string
28
+ /**
29
+ * A product affiliation to designate a supplying company or brick and mortar store location.
30
+ */
31
+ affiliation?: string
32
+ /**
33
+ * Coupon code used for a purchase.
34
+ */
35
+ coupon?: string
36
+ /**
37
+ * Currency of the purchase or items associated with the event, in 3-letter ISO 4217 format.
38
+ */
39
+ currency?: string
40
+ /**
41
+ * Monetary value of discount associated with a purchase.
42
+ */
43
+ discount?: number
44
+ /**
45
+ * The index/position of the item in a list.
46
+ */
47
+ index?: number
48
+ /**
49
+ * Brand associated with the product.
50
+ */
51
+ item_brand?: string
52
+ /**
53
+ * Product category.
54
+ */
55
+ item_category?: string
56
+ /**
57
+ * Product category 2.
58
+ */
59
+ item_category2?: string
60
+ /**
61
+ * Product category 3.
62
+ */
63
+ item_category3?: string
64
+ /**
65
+ * Product category 4.
66
+ */
67
+ item_category4?: string
68
+ /**
69
+ * Product category 5.
70
+ */
71
+ item_category5?: string
72
+ /**
73
+ * The ID of the list in which the item was presented to the user.
74
+ */
75
+ item_list_id?: string
76
+ /**
77
+ * The name of the list in which the item was presented to the user.
78
+ */
79
+ item_list_name?: string
80
+ /**
81
+ * Variant of the product (e.g. Black).
82
+ */
83
+ item_variant?: string
84
+ /**
85
+ * The location associated with the item.
86
+ */
87
+ location_id?: string
88
+ /**
89
+ * Price of the product being purchased, in units of the specified currency parameter.
90
+ */
91
+ price?: number
92
+ /**
93
+ * Item quantity.
94
+ */
95
+ quantity?: number
96
+ }[]
97
+ /**
98
+ * The unique identifier of a transaction.
99
+ */
100
+ transaction_id: string
101
+ /**
102
+ * Shipping cost associated with the transaction.
103
+ */
104
+ shipping?: number
105
+ /**
106
+ * Total tax associated with the transaction.
107
+ */
108
+ tax?: number
109
+ /**
110
+ * The monetary value of the event.
111
+ */
112
+ value?: number
113
+ /**
114
+ * The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s [Custom user properties](https://support.google.com/analytics/answer/9269570) to learn how to set and register user properties.
115
+ */
116
+ user_properties?: {
117
+ [k: string]: unknown
118
+ }
119
+ /**
120
+ * The event parameters to send to Google Analytics 4.
121
+ */
122
+ params?: {
123
+ [k: string]: unknown
124
+ }
125
+ }
@@ -0,0 +1,54 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types'
2
+ import type { Settings } from '../generated-types'
3
+ import type { Payload } from './generated-types'
4
+ import {
5
+ coupon,
6
+ currency,
7
+ transaction_id,
8
+ value,
9
+ user_id,
10
+ shipping,
11
+ tax,
12
+ items_multi_products,
13
+ params,
14
+ user_properties
15
+ } from '../ga4-properties'
16
+ import { updateUser } from '../ga4-functions'
17
+
18
+ const action: BrowserActionDefinition<Settings, Function, Payload> = {
19
+ title: 'Purchase',
20
+ description: 'This event signifies when one or more items is purchased by a user.',
21
+ defaultSubscription: 'type = "track" and event = "Order Completed"',
22
+ platform: 'web',
23
+ fields: {
24
+ user_id: user_id,
25
+ coupon: { ...coupon, default: { '@path': '$.properties.coupon' } },
26
+ currency: { ...currency, required: true },
27
+ items: {
28
+ ...items_multi_products,
29
+ required: true
30
+ },
31
+ transaction_id: { ...transaction_id, required: true },
32
+ shipping: shipping,
33
+ tax: tax,
34
+ value: { ...value, default: { '@path': '$.properties.total' } },
35
+ user_properties: user_properties,
36
+ params: params
37
+ },
38
+ perform: (gtag, { payload }) => {
39
+ updateUser(payload.user_id, payload.user_properties, gtag)
40
+
41
+ gtag('event', 'purchase', {
42
+ currency: payload.currency,
43
+ transaction_id: payload.transaction_id,
44
+ value: payload.value,
45
+ coupon: payload.coupon,
46
+ tax: payload.tax,
47
+ shipping: payload.shipping,
48
+ items: payload.items,
49
+ ...payload.params
50
+ })
51
+ }
52
+ }
53
+
54
+ export default action
@@ -0,0 +1,129 @@
1
+ // Generated file. DO NOT MODIFY IT BY HAND.
2
+
3
+ export interface Payload {
4
+ /**
5
+ * A unique identifier for a user. See Google's [User-ID for cross-platform analysis](https://support.google.com/analytics/answer/9213390) and [Reporting: deduplicate user counts](https://support.google.com/analytics/answer/9355949?hl=en) documentation for more information on this identifier.
6
+ */
7
+ user_id?: string
8
+ /**
9
+ * Currency of the items associated with the event, in 3-letter ISO 4217 format.
10
+ */
11
+ currency?: string
12
+ /**
13
+ * The unique identifier of a transaction.
14
+ */
15
+ transaction_id: string
16
+ /**
17
+ * The monetary value of the event.
18
+ */
19
+ value?: number
20
+ /**
21
+ * Store or affiliation from which this transaction occurred (e.g. Google Store).
22
+ */
23
+ affiliation?: string
24
+ /**
25
+ * Coupon code used for a purchase.
26
+ */
27
+ coupon?: string
28
+ /**
29
+ * Shipping cost associated with the transaction.
30
+ */
31
+ shipping?: number
32
+ /**
33
+ * Total tax associated with the transaction.
34
+ */
35
+ tax?: number
36
+ /**
37
+ * The list of products purchased.
38
+ */
39
+ items?: {
40
+ /**
41
+ * Identifier for the product being purchased.
42
+ */
43
+ item_id?: string
44
+ /**
45
+ * Name of the product being purchased.
46
+ */
47
+ item_name?: string
48
+ /**
49
+ * A product affiliation to designate a supplying company or brick and mortar store location.
50
+ */
51
+ affiliation?: string
52
+ /**
53
+ * Coupon code used for a purchase.
54
+ */
55
+ coupon?: string
56
+ /**
57
+ * Currency of the purchase or items associated with the event, in 3-letter ISO 4217 format.
58
+ */
59
+ currency?: string
60
+ /**
61
+ * Monetary value of discount associated with a purchase.
62
+ */
63
+ discount?: number
64
+ /**
65
+ * The index/position of the item in a list.
66
+ */
67
+ index?: number
68
+ /**
69
+ * Brand associated with the product.
70
+ */
71
+ item_brand?: string
72
+ /**
73
+ * Product category.
74
+ */
75
+ item_category?: string
76
+ /**
77
+ * Product category 2.
78
+ */
79
+ item_category2?: string
80
+ /**
81
+ * Product category 3.
82
+ */
83
+ item_category3?: string
84
+ /**
85
+ * Product category 4.
86
+ */
87
+ item_category4?: string
88
+ /**
89
+ * Product category 5.
90
+ */
91
+ item_category5?: string
92
+ /**
93
+ * The ID of the list in which the item was presented to the user.
94
+ */
95
+ item_list_id?: string
96
+ /**
97
+ * The name of the list in which the item was presented to the user.
98
+ */
99
+ item_list_name?: string
100
+ /**
101
+ * Variant of the product (e.g. Black).
102
+ */
103
+ item_variant?: string
104
+ /**
105
+ * The location associated with the item.
106
+ */
107
+ location_id?: string
108
+ /**
109
+ * Price of the product being purchased, in units of the specified currency parameter.
110
+ */
111
+ price?: number
112
+ /**
113
+ * Item quantity.
114
+ */
115
+ quantity?: number
116
+ }[]
117
+ /**
118
+ * The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s [Custom user properties](https://support.google.com/analytics/answer/9269570) to learn how to set and register user properties.
119
+ */
120
+ user_properties?: {
121
+ [k: string]: unknown
122
+ }
123
+ /**
124
+ * The event parameters to send to Google Analytics 4.
125
+ */
126
+ params?: {
127
+ [k: string]: unknown
128
+ }
129
+ }
@@ -0,0 +1,57 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types'
2
+ import type { Settings } from '../generated-types'
3
+ import type { Payload } from './generated-types'
4
+
5
+ import {
6
+ coupon,
7
+ transaction_id,
8
+ user_id,
9
+ currency,
10
+ value,
11
+ affiliation,
12
+ shipping,
13
+ items_multi_products,
14
+ params,
15
+ user_properties,
16
+ tax
17
+ } from '../ga4-properties'
18
+ import { updateUser } from '../ga4-functions'
19
+
20
+ const action: BrowserActionDefinition<Settings, Function, Payload> = {
21
+ title: 'Refund',
22
+ description: 'This event signifies when one or more items is refunded to a user.',
23
+ defaultSubscription: 'type = "track" and event = "Order Refunded"',
24
+ platform: 'web',
25
+ fields: {
26
+ user_id: user_id,
27
+ currency: currency,
28
+ transaction_id: { ...transaction_id, required: true },
29
+ value: { ...value, default: { '@path': '$.properties.total' } },
30
+ affiliation: affiliation,
31
+ coupon: coupon,
32
+ shipping: shipping,
33
+ tax: tax,
34
+ items: {
35
+ ...items_multi_products
36
+ },
37
+ user_properties: user_properties,
38
+ params: params
39
+ },
40
+ perform: (gtag, { payload }) => {
41
+ updateUser(payload.user_id, payload.user_properties, gtag)
42
+
43
+ gtag('event', 'refund', {
44
+ currency: payload.currency,
45
+ transaction_id: payload.transaction_id, // Transaction ID. Required for purchases and refunds.
46
+ value: payload.value,
47
+ affiliation: payload.affiliation,
48
+ coupon: payload.coupon,
49
+ shipping: payload.shipping,
50
+ tax: payload.tax,
51
+ items: payload.items,
52
+ ...payload.params
53
+ })
54
+ }
55
+ }
56
+
57
+ export default action