-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGtmPlugin.js
30 lines (29 loc) · 878 Bytes
/
GtmPlugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export default class GtmPlugin {
trackView(screenName, path) {
let dataLayer = (window.dataLayer = window.dataLayer || []);
dataLayer.push({
event: 'content-view',
'content-name': path
});
}
trackEvent({
event = null,
category = null,
action = null,
label = null,
value = null,
noninteraction = false,
...rest
} = {}) {
let dataLayer = (window.dataLayer = window.dataLayer || []);
dataLayer.push({
event: event || 'interaction',
target: category,
action: action,
'target-properties': label,
value: value,
'interaction-type': noninteraction,
...rest
});
}
}