-
Notifications
You must be signed in to change notification settings - Fork 3
/
tag-rocket-bcee-modifications.html
47 lines (42 loc) · 1.94 KB
/
tag-rocket-bcee-modifications.html
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script data-cfasync="false">
/*
Web Site Advantage: Tag Rocket BCEE Modifications [v1.1]
Modify the events sent by the BigCommerce Enhanced Ecommerce solution
https://bigcommerce.websiteadvantage.com.au/tag-rocket/articles/tag-rocket-api/
Copyright (C) 2022 Web Site Advantage
*/
!function(w,t){
w[t]=w[t]||{};var T=w[t];T.i=T.i||[];if(!T.init)T.init=function(f){T.i.push(f)};
T.init(function() {
var requireEcDone = false;
T.on('GaCommandPending',function(data, eventName){
// fires before a command is sent, giving you the ability to edit the arguments or stop it from being sent by setting cancel to true
switch(data.arguments[0]) {
case "create":
// You could modify things like the sample rate
data.arguments[2].sampleRate = 50;
// It seems the name they used here is wrong
delete data.arguments[2].useGoogleAmpClientId;
data.arguments[2].useAmpClientId = true;
break;
case "linker:autoLink":
// add your own linker domains for cross domain tracking
// Tag Rocket admin also lets you add domains
data.arguments[1].push('myotherdomain.com');
break;
case "require":
if (data.arguments[1] === 'ec') {
// require ec is called twice causing an error in the GA debugger. This stops it.
if (requireEcDone) {
data.cancel = true; // this will stop the event from being sent.
}
else {
requireEcDone = true;
}
}
break;
}
});
})
}(window,"TagRocket")
</script>