-
Notifications
You must be signed in to change notification settings - Fork 1
/
duplicate-revenue-events.html
36 lines (32 loc) · 1.45 KB
/
duplicate-revenue-events.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
<html>
<head>
</head>
<body>
<script>
(function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="https://cdn.branch.io/branch-latest.min.js";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode autoAppIndex banner closeBanner closeJourney creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setBranchViewData setIdentity track validateCode trackCommerceEvent".split(" "), 0);
branch.init('key_live_pbtE4dcavETgqI5C3M8n0eabADiL8rYZ', function(err, data){
console.log('data from Branch', data);
console.log('err from Branch', err);
});
var commerce_data = {
"revenue": 50.0,
"currency": "USD",
"transaction_id": "foo-transaction-id",
"shipping": 0.0,
"tax": 5.0,
"affiliation": "foo-affiliation",
"products": [
{ "sku": "foo-sku-1", "name": "foo-item-1", "price": 45.00, "quantity": 1, "brand": "foo-brand",
"category": "Electronics", "variant": "foo-variant-1"},
{ "sku": "foo-sku-2", "price": 2.50, "quantity": 2}
],
};
var metadata = { "foo": "bar" };
branch.trackCommerceEvent('purchase', commerce_data, metadata, function(err) {
if(err) {
throw err;
}
});
</script>
</body>
</html>