@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.
- package/package.json +20 -0
- package/src/__tests__/addPaymentInfo.test.ts +101 -0
- package/src/__tests__/addToCart.test.ts +95 -0
- package/src/__tests__/addToWishlist.test.ts +95 -0
- package/src/__tests__/beginCheckout.test.ts +101 -0
- package/src/__tests__/customEvent.test.ts +70 -0
- package/src/__tests__/generateLead.test.ts +68 -0
- package/src/__tests__/login.test.ts +63 -0
- package/src/__tests__/purchase.test.ts +103 -0
- package/src/__tests__/refund.test.ts +103 -0
- package/src/__tests__/removeFromCart.test.ts +99 -0
- package/src/__tests__/search.test.ts +64 -0
- package/src/__tests__/selectItem.test.ts +96 -0
- package/src/__tests__/selectPromotion.test.ts +111 -0
- package/src/__tests__/signUp.test.ts +62 -0
- package/src/__tests__/viewCart.test.ts +96 -0
- package/src/__tests__/viewItem.test.ts +96 -0
- package/src/__tests__/viewItemList.test.ts +96 -0
- package/src/__tests__/viewPromotion.test.ts +111 -0
- package/src/addPaymentInfo/generated-types.ts +117 -0
- package/src/addPaymentInfo/index.ts +48 -0
- package/src/addToCart/generated-types.ts +109 -0
- package/src/addToCart/index.ts +36 -0
- package/src/addToWishlist/generated-types.ts +109 -0
- package/src/addToWishlist/index.ts +38 -0
- package/src/beginCheckout/generated-types.ts +113 -0
- package/src/beginCheckout/index.ts +38 -0
- package/src/customEvent/generated-types.ts +28 -0
- package/src/customEvent/index.ts +52 -0
- package/src/ga4-functions.ts +8 -0
- package/src/ga4-properties.ts +368 -0
- package/src/ga4-types.ts +28 -0
- package/src/generateLead/generated-types.ts +28 -0
- package/src/generateLead/index.ts +32 -0
- package/src/generated-types.ts +56 -0
- package/src/index.ts +194 -0
- package/src/login/generated-types.ts +24 -0
- package/src/login/index.ts +31 -0
- package/src/purchase/generated-types.ts +125 -0
- package/src/purchase/index.ts +54 -0
- package/src/refund/generated-types.ts +129 -0
- package/src/refund/index.ts +57 -0
- package/src/removeFromCart/generated-types.ts +109 -0
- package/src/removeFromCart/index.ts +37 -0
- package/src/search/generated-types.ts +24 -0
- package/src/search/index.ts +30 -0
- package/src/selectItem/generated-types.ts +109 -0
- package/src/selectItem/index.ts +43 -0
- package/src/selectPromotion/generated-types.ts +137 -0
- package/src/selectPromotion/index.ts +67 -0
- package/src/setConfigurationFields/generated-types.ts +70 -0
- package/src/setConfigurationFields/index.ts +143 -0
- package/src/signUp/generated-types.ts +24 -0
- package/src/signUp/index.ts +29 -0
- package/src/types.ts +3 -0
- package/src/viewCart/generated-types.ts +109 -0
- package/src/viewCart/index.ts +36 -0
- package/src/viewItem/generated-types.ts +109 -0
- package/src/viewItem/index.ts +37 -0
- package/src/viewItemList/generated-types.ts +109 -0
- package/src/viewItemList/index.ts +36 -0
- package/src/viewPromotion/generated-types.ts +137 -0
- package/src/viewPromotion/index.ts +67 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,109 @@
|
|
|
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 monetary value of the event.
|
|
14
|
+
*/
|
|
15
|
+
value?: number
|
|
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 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.
|
|
99
|
+
*/
|
|
100
|
+
user_properties?: {
|
|
101
|
+
[k: string]: unknown
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The event parameters to send to Google Analytics 4.
|
|
105
|
+
*/
|
|
106
|
+
params?: {
|
|
107
|
+
[k: string]: unknown
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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, value, user_id, currency, items_single_products } 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: 'Remove from Cart',
|
|
11
|
+
description: 'This event signifies that an item was removed from a cart.',
|
|
12
|
+
platform: 'web',
|
|
13
|
+
defaultSubscription: 'type = "track" and event = "Product Removed"',
|
|
14
|
+
fields: {
|
|
15
|
+
user_id: user_id,
|
|
16
|
+
currency: currency,
|
|
17
|
+
value: value,
|
|
18
|
+
items: {
|
|
19
|
+
...items_single_products,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
user_properties: user_properties,
|
|
23
|
+
params: params
|
|
24
|
+
},
|
|
25
|
+
perform: (gtag, { payload }) => {
|
|
26
|
+
updateUser(payload.user_id, payload.user_properties, gtag)
|
|
27
|
+
|
|
28
|
+
gtag('event', 'remove_from_cart', {
|
|
29
|
+
currency: payload.currency,
|
|
30
|
+
value: payload.value,
|
|
31
|
+
items: payload.items,
|
|
32
|
+
...payload.params
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default action
|
|
@@ -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 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.
|
|
10
|
+
*/
|
|
11
|
+
user_properties?: {
|
|
12
|
+
[k: string]: unknown
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The event parameters to send to Google Analytics 4.
|
|
16
|
+
*/
|
|
17
|
+
params?: {
|
|
18
|
+
[k: string]: unknown
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The term that was searched for.
|
|
22
|
+
*/
|
|
23
|
+
search_term?: string
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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, search_term } 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: 'Search',
|
|
11
|
+
description: 'The term that was searched for.',
|
|
12
|
+
defaultSubscription: 'type = "track" and event = "Products Searched"',
|
|
13
|
+
platform: 'web',
|
|
14
|
+
fields: {
|
|
15
|
+
user_id: user_id,
|
|
16
|
+
user_properties: user_properties,
|
|
17
|
+
params: params,
|
|
18
|
+
search_term: search_term
|
|
19
|
+
},
|
|
20
|
+
perform: (gtag, { payload }) => {
|
|
21
|
+
updateUser(payload.user_id, payload.user_properties, gtag)
|
|
22
|
+
|
|
23
|
+
gtag('event', 'search', {
|
|
24
|
+
search_term: payload.search_term,
|
|
25
|
+
...payload.params
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default action
|
|
@@ -0,0 +1,109 @@
|
|
|
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 name of the list in which the item was presented to the user.
|
|
10
|
+
*/
|
|
11
|
+
item_list_name?: string
|
|
12
|
+
/**
|
|
13
|
+
* The ID of the list in which the item was presented to the user.
|
|
14
|
+
*/
|
|
15
|
+
item_list_id?: 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 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.
|
|
99
|
+
*/
|
|
100
|
+
user_properties?: {
|
|
101
|
+
[k: string]: unknown
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The event parameters to send to Google Analytics 4.
|
|
105
|
+
*/
|
|
106
|
+
params?: {
|
|
107
|
+
[k: string]: unknown
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
user_properties,
|
|
7
|
+
params,
|
|
8
|
+
user_id,
|
|
9
|
+
items_single_products,
|
|
10
|
+
item_list_name,
|
|
11
|
+
item_list_id
|
|
12
|
+
} from '../ga4-properties'
|
|
13
|
+
import { updateUser } from '../ga4-functions'
|
|
14
|
+
|
|
15
|
+
const action: BrowserActionDefinition<Settings, Function, Payload> = {
|
|
16
|
+
title: 'Select Item',
|
|
17
|
+
description: 'This event signifies an item was selected from a list.',
|
|
18
|
+
defaultSubscription: 'type = "track" and event = "Product Clicked"',
|
|
19
|
+
platform: 'web',
|
|
20
|
+
fields: {
|
|
21
|
+
user_id: user_id,
|
|
22
|
+
item_list_name: item_list_name,
|
|
23
|
+
item_list_id: item_list_id,
|
|
24
|
+
items: {
|
|
25
|
+
...items_single_products,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
user_properties: user_properties,
|
|
29
|
+
params: params
|
|
30
|
+
},
|
|
31
|
+
perform: (gtag, { payload }) => {
|
|
32
|
+
updateUser(payload.user_id, payload.user_properties, gtag)
|
|
33
|
+
|
|
34
|
+
gtag('event', 'select_item', {
|
|
35
|
+
item_list_id: payload.item_list_id,
|
|
36
|
+
item_list_name: payload.item_list_name,
|
|
37
|
+
items: payload.items,
|
|
38
|
+
...payload.params
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default action
|
|
@@ -0,0 +1,137 @@
|
|
|
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 name of the promotional creative.
|
|
10
|
+
*/
|
|
11
|
+
creative_name?: string
|
|
12
|
+
/**
|
|
13
|
+
* The name of the promotional creative slot associated with the event.
|
|
14
|
+
*/
|
|
15
|
+
creative_slot?: string
|
|
16
|
+
/**
|
|
17
|
+
* The ID of the location.
|
|
18
|
+
*/
|
|
19
|
+
location_id?: string
|
|
20
|
+
/**
|
|
21
|
+
* The ID of the promotion associated with the event.
|
|
22
|
+
*/
|
|
23
|
+
promotion_id?: string
|
|
24
|
+
/**
|
|
25
|
+
* The name of the promotion associated with the event.
|
|
26
|
+
*/
|
|
27
|
+
promotion_name?: string
|
|
28
|
+
/**
|
|
29
|
+
* The list of products purchased.
|
|
30
|
+
*/
|
|
31
|
+
items?: {
|
|
32
|
+
/**
|
|
33
|
+
* Identifier for the product being purchased.
|
|
34
|
+
*/
|
|
35
|
+
item_id?: string
|
|
36
|
+
/**
|
|
37
|
+
* Name of the product being purchased.
|
|
38
|
+
*/
|
|
39
|
+
item_name?: string
|
|
40
|
+
/**
|
|
41
|
+
* A product affiliation to designate a supplying company or brick and mortar store location.
|
|
42
|
+
*/
|
|
43
|
+
affiliation?: string
|
|
44
|
+
/**
|
|
45
|
+
* Coupon code used for a purchase.
|
|
46
|
+
*/
|
|
47
|
+
coupon?: string
|
|
48
|
+
/**
|
|
49
|
+
* Currency of the purchase or items associated with the event, in 3-letter ISO 4217 format.
|
|
50
|
+
*/
|
|
51
|
+
currency?: string
|
|
52
|
+
/**
|
|
53
|
+
* Monetary value of discount associated with a purchase.
|
|
54
|
+
*/
|
|
55
|
+
discount?: number
|
|
56
|
+
/**
|
|
57
|
+
* The index/position of the item in a list.
|
|
58
|
+
*/
|
|
59
|
+
index?: number
|
|
60
|
+
/**
|
|
61
|
+
* Brand associated with the product.
|
|
62
|
+
*/
|
|
63
|
+
item_brand?: string
|
|
64
|
+
/**
|
|
65
|
+
* Product category.
|
|
66
|
+
*/
|
|
67
|
+
item_category?: string
|
|
68
|
+
/**
|
|
69
|
+
* Product category 2.
|
|
70
|
+
*/
|
|
71
|
+
item_category2?: string
|
|
72
|
+
/**
|
|
73
|
+
* Product category 3.
|
|
74
|
+
*/
|
|
75
|
+
item_category3?: string
|
|
76
|
+
/**
|
|
77
|
+
* Product category 4.
|
|
78
|
+
*/
|
|
79
|
+
item_category4?: string
|
|
80
|
+
/**
|
|
81
|
+
* Product category 5.
|
|
82
|
+
*/
|
|
83
|
+
item_category5?: string
|
|
84
|
+
/**
|
|
85
|
+
* The ID of the list in which the item was presented to the user.
|
|
86
|
+
*/
|
|
87
|
+
item_list_id?: string
|
|
88
|
+
/**
|
|
89
|
+
* The name of the list in which the item was presented to the user.
|
|
90
|
+
*/
|
|
91
|
+
item_list_name?: string
|
|
92
|
+
/**
|
|
93
|
+
* Variant of the product (e.g. Black).
|
|
94
|
+
*/
|
|
95
|
+
item_variant?: string
|
|
96
|
+
/**
|
|
97
|
+
* The location associated with the item.
|
|
98
|
+
*/
|
|
99
|
+
location_id?: string
|
|
100
|
+
/**
|
|
101
|
+
* Price of the product being purchased, in units of the specified currency parameter.
|
|
102
|
+
*/
|
|
103
|
+
price?: number
|
|
104
|
+
/**
|
|
105
|
+
* Item quantity.
|
|
106
|
+
*/
|
|
107
|
+
quantity?: number
|
|
108
|
+
/**
|
|
109
|
+
* The name of the promotional creative.
|
|
110
|
+
*/
|
|
111
|
+
creative_name?: string
|
|
112
|
+
/**
|
|
113
|
+
* The name of the promotional creative slot associated with the event.
|
|
114
|
+
*/
|
|
115
|
+
creative_slot?: string
|
|
116
|
+
/**
|
|
117
|
+
* The name of the promotion associated with the event.
|
|
118
|
+
*/
|
|
119
|
+
promotion_name?: string
|
|
120
|
+
/**
|
|
121
|
+
* The ID of the promotion associated with the event.
|
|
122
|
+
*/
|
|
123
|
+
promotion_id?: string
|
|
124
|
+
}[]
|
|
125
|
+
/**
|
|
126
|
+
* 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.
|
|
127
|
+
*/
|
|
128
|
+
user_properties?: {
|
|
129
|
+
[k: string]: unknown
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The event parameters to send to Google Analytics 4.
|
|
133
|
+
*/
|
|
134
|
+
params?: {
|
|
135
|
+
[k: string]: unknown
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
creative_name,
|
|
7
|
+
user_id,
|
|
8
|
+
creative_slot,
|
|
9
|
+
promotion_id,
|
|
10
|
+
promotion_name,
|
|
11
|
+
minimal_items,
|
|
12
|
+
items_single_products,
|
|
13
|
+
params,
|
|
14
|
+
user_properties,
|
|
15
|
+
location_id
|
|
16
|
+
} from '../ga4-properties'
|
|
17
|
+
import { updateUser } from '../ga4-functions'
|
|
18
|
+
|
|
19
|
+
const action: BrowserActionDefinition<Settings, Function, Payload> = {
|
|
20
|
+
title: 'Select Promotion',
|
|
21
|
+
description: 'This event signifies a promotion was selected from a list.',
|
|
22
|
+
defaultSubscription: 'type = "track" and event = "Promotion Clicked"',
|
|
23
|
+
platform: 'web',
|
|
24
|
+
fields: {
|
|
25
|
+
user_id: user_id,
|
|
26
|
+
creative_name: creative_name,
|
|
27
|
+
creative_slot: { ...creative_slot, default: { '@path': '$.properties.creative' } },
|
|
28
|
+
location_id: location_id,
|
|
29
|
+
promotion_id: { ...promotion_id, default: { '@path': '$.properties.promotion_id' } },
|
|
30
|
+
promotion_name: { ...promotion_name, default: { '@path': '$.properties.name' } },
|
|
31
|
+
items: {
|
|
32
|
+
...items_single_products,
|
|
33
|
+
properties: {
|
|
34
|
+
...minimal_items.properties,
|
|
35
|
+
creative_name: {
|
|
36
|
+
...creative_name
|
|
37
|
+
},
|
|
38
|
+
creative_slot: {
|
|
39
|
+
...creative_slot
|
|
40
|
+
},
|
|
41
|
+
promotion_name: {
|
|
42
|
+
...promotion_name
|
|
43
|
+
},
|
|
44
|
+
promotion_id: {
|
|
45
|
+
...promotion_id
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
user_properties: user_properties,
|
|
50
|
+
params: params
|
|
51
|
+
},
|
|
52
|
+
perform: (gtag, { payload }) => {
|
|
53
|
+
updateUser(payload.user_id, payload.user_properties, gtag)
|
|
54
|
+
|
|
55
|
+
gtag('event', 'select_promotion', {
|
|
56
|
+
creative_name: payload.creative_name,
|
|
57
|
+
creative_slot: payload.creative_slot,
|
|
58
|
+
location_id: payload.location_id,
|
|
59
|
+
promotion_id: payload.promotion_id,
|
|
60
|
+
promotion_name: payload.promotion_name,
|
|
61
|
+
items: payload.items,
|
|
62
|
+
...payload.params
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default action
|
|
@@ -0,0 +1,70 @@
|
|
|
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 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.
|
|
10
|
+
*/
|
|
11
|
+
user_properties?: {
|
|
12
|
+
[k: string]: unknown
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.
|
|
16
|
+
*/
|
|
17
|
+
ads_storage_consent_state?: string
|
|
18
|
+
/**
|
|
19
|
+
* Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.
|
|
20
|
+
*/
|
|
21
|
+
analytics_storage_consent_state?: string
|
|
22
|
+
/**
|
|
23
|
+
* Use campaign content to differentiate ads or links that point to the same URL. Setting this value will override the utm_content query parameter.
|
|
24
|
+
*/
|
|
25
|
+
campaign_content?: string
|
|
26
|
+
/**
|
|
27
|
+
* Use campaign ID to identify a specific campaign. Setting this value will override the utm_id query parameter.
|
|
28
|
+
*/
|
|
29
|
+
campaign_id?: string
|
|
30
|
+
/**
|
|
31
|
+
* Use campaign medium to identify a medium such as email or cost-per-click. Setting this value will override the utm_medium query parameter.
|
|
32
|
+
*/
|
|
33
|
+
campaign_medium?: string
|
|
34
|
+
/**
|
|
35
|
+
* Use campaign name to identify a specific product promotion or strategic campaign. Setting this value will override the utm_name query parameter.
|
|
36
|
+
*/
|
|
37
|
+
campaign_name?: string
|
|
38
|
+
/**
|
|
39
|
+
* Use campaign source to identify a search engine, newsletter name, or other source. Setting this value will override the utm_source query parameter.
|
|
40
|
+
*/
|
|
41
|
+
campaign_source?: string
|
|
42
|
+
/**
|
|
43
|
+
* Use campaign term to note the keywords for this ad. Setting this value will override the utm_term query parameter.
|
|
44
|
+
*/
|
|
45
|
+
campaign_term?: string
|
|
46
|
+
/**
|
|
47
|
+
* Categorize pages and screens into custom buckets so you can see metrics for related groups of information. More information in [Google documentation](https://support.google.com/analytics/answer/11523339).
|
|
48
|
+
*/
|
|
49
|
+
content_group?: string
|
|
50
|
+
/**
|
|
51
|
+
* The language preference of the user. If not set, defaults to the user's navigator.language value.
|
|
52
|
+
*/
|
|
53
|
+
language?: string
|
|
54
|
+
/**
|
|
55
|
+
* The full URL of the page. If not set, defaults to the user's document.location value.
|
|
56
|
+
*/
|
|
57
|
+
page_location?: string
|
|
58
|
+
/**
|
|
59
|
+
* The referral source that brought traffic to a page. This value is also used to compute the traffic source. The format of this value is a URL. If not set, defaults to the user's document.referrer value.
|
|
60
|
+
*/
|
|
61
|
+
page_referrer?: string
|
|
62
|
+
/**
|
|
63
|
+
* The title of the page or document. If not set, defaults to the user's document.title value.
|
|
64
|
+
*/
|
|
65
|
+
page_title?: string
|
|
66
|
+
/**
|
|
67
|
+
* The resolution of the screen. Format should be two positive integers separated by an x (i.e. 800x600). If not set, calculated from the user's window.screen value.
|
|
68
|
+
*/
|
|
69
|
+
screen_resolution?: string
|
|
70
|
+
}
|