-
Notifications
You must be signed in to change notification settings - Fork 3
/
tag-rocket-stop-conversions-example.html
53 lines (47 loc) · 2.3 KB
/
tag-rocket-stop-conversions-example.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
48
49
50
51
52
53
<script data-cfasync="false">
/*
Web Site Advantage: Tag Rocket Disable ga conversion event Example [v1.0]
Don't track a conversion if it has a payment method of Apply for finance
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() {
T.on('CheckoutStep5OrderCompleted',function(data, eventName){
if (data.paymentMethod === "Apply for finance") {
data.cancelBuiltInEvents = true;
}
});
// GA is separate as is not powered by Tag Rocket
// this may work but is dependent on Tag Rocket getting the order (a request) before BC EE sends its events.
T.on('GaCommandPending',function(data, eventName){
if (T.order && T.order.paymentMethod === "Apply for finance") {
if (data.arguments.length >=2) {
var command = data.arguments[0];
var event = data.arguments[1];
switch (command) {
case 'ec:addProduct':
data.cancel = true;
break;
case 'ec:setAction':
if (event === 'purchase') {
data.cancel = true;
}
break;
case 'send':
if (data.arguments.length >=4) {
var type = data.arguments[2];
var eventName = data.arguments[3];
if (event === 'event' && type === 'EnhancedEcommerce' && eventName === 'Order Completed') {
data.cancel = true;
}
}
break;
}
}
}
})
})
}(window,"TagRocket")
</script>