forked from monster-site/monster-site.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
branch_events.js
44 lines (36 loc) · 1.16 KB
/
branch_events.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function trackEvent(eventName) {
if (eventName == "ADD_TO_CART") {
var event_and_custom_data = {
"currency": "EUR",
"revenue": 120.0,
"coupon": "coupon_code"
};
var customer_event_alias = "Test currency + revenue + coupon fields";
branch.logEvent(
"ADD_TO_CART",
event_and_custom_data,
customer_event_alias,
function(err) { console.log(err); }
);
setTimeout(function(){alert("Branch " + eventName + " event was tracked with currency, revenue, and coupon data!")},500);
}
else if(eventName == "PURCHASE") {
var event_and_custom_data = {
"currency": "EUR",
"revenue": 120.0,
"coupon": "coupon_code"
};
var customer_event_alias = "Test currency + revenue + coupon fields";
branch.logEvent(
"PURCHASE",
event_and_custom_data,
customer_event_alias,
function(err) { console.log(err); }
);
setTimeout(function(){alert("Branch " + eventName + " event was tracked with currency, revenue, and coupon data!")},500);
}
else {
branch.logEvent(eventName);
setTimeout(function(){alert("Branch " + eventName + " event was tracked!")},500);
}
}