Skip to content

Commit 720cc26

Browse files
authored
Merge pull request #328 from BranchMetrics/fix-cordova
added commerce events
2 parents 5661e0a + 572a889 commit 720cc26

File tree

13 files changed

+579
-44
lines changed

13 files changed

+579
-44
lines changed

README.md

Lines changed: 271 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [Track Content](#track-content)
3838
- [Track User](#track-user)
3939
- [Track Event](#track-event)
40+
- [Track Commerce](#track-commerce)
4041
- [Handle Referrals](#handle-referrals)
4142
- [Troubleshooting](#troubleshooting)
4243
- [Testing: Key Points](#testing-key-points)
@@ -47,6 +48,7 @@
4748
- [Testing: Sample Test App](#testing-sample-test-app)
4849
- [Link Data: Universal Object Properties](#link-data-universal-object-properties)
4950
- [Link Data: Deep Link Properties](#link-data-deep-link-properties)
51+
- [Link Data: Commerce Properties](#link-data-commerce-properties)
5052
- [Compiling: Cordova Dependencies](#compiling-cordova-dependencies)
5153
- [Compiling: Show Console Logs](#compiling-show-console-logs)
5254
- [Compiling: Updating the Branch SDK](#compiling-updating-the-branch-sdk)
@@ -69,7 +71,7 @@
6971
<!-- sample config.xml -->
7072
<widget id="com.eneff.branch.cordovatestbed" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
7173
<!-- Branch -->
72-
<plugin name="branch-cordova-sdk" spec="^2.5.0" />
74+
<plugin name="branch-cordova-sdk" spec="^2.6.0" />
7375
<branch-config>
7476
<branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
7577
<uri-scheme value="branchcordova" />
@@ -83,7 +85,7 @@
8385
<!-- sample config.xml -->
8486
<widget id="com.eneff.branch.cordovatestbed" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
8587
<!-- Branch -->
86-
<plugin name="branch-cordova-sdk" spec="^2.5.0" />
88+
<plugin name="branch-cordova-sdk" spec="^2.6.0" />
8789
<branch-config>
8890
<branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
8991
<uri-scheme value="branchcordova" />
@@ -476,11 +478,11 @@
476478

477479
- #### Track Event
478480

479-
- Registers custom events
481+
- Registers a custom event
480482

481483
- Events named `open`, `close`, `install`, and `referred session` are Branch restricted
482484

483-
- Recommened to [Track User](#track-user) before [Track Event](#track-event) to associate custom events with a user
485+
- Recommended to [Track User](#track-user) before [Track Event](#track-event) to associate custom events with a user
484486

485487
- Verify on the [Branch Dashboard](https://dashboard.branch.io/liveview/events)
486488

@@ -503,6 +505,60 @@
503505
})
504506
```
505507

508+
- #### Track Commerce
509+
510+
- Registers a custom commerce event
511+
512+
- Recommended to [Track User](#track-user) before [Track Commerce](#track-commerce) to associate commerce events with a user
513+
514+
- [Track commerce properties](#link-data-commerce-properties) for `Currency` and `Category`
515+
516+
- Verify on the [Branch Dashboard](https://dashboard.branch.io/liveview/commerce)
517+
518+
```js
519+
// only revenue is required
520+
var event = {
521+
'revenue': 50.29,
522+
'currency': 148, // USD
523+
'transactionID': 'transaction id',
524+
'coupon': 'coupon',
525+
'shipping': 2.22,
526+
'tax': 5.11,
527+
'affiliation': 'affiliation',
528+
'products': [
529+
{
530+
'sku': 'u123',
531+
'name': 'cactus',
532+
'price': 4.99,
533+
'quantity': 2,
534+
'brand': 'brand',
535+
'category': 17, // Software
536+
'variant': 'variant'
537+
},
538+
{
539+
'sku': 'u456',
540+
'name': 'grass',
541+
'price': 0.00,
542+
'quantity': 1
543+
}
544+
]
545+
}
546+
547+
// optional fields
548+
var metadata = {
549+
'custom_dictionary': 123,
550+
'anything': 'everything'
551+
}
552+
553+
Branch.sendCommerceEvent(event, metadata).then(function (res) {
554+
console.log(res)
555+
alert('Response: ' + JSON.stringify(res))
556+
}).catch(function (err) {
557+
console.error(err)
558+
alert('Error: ' + JSON.stringify(err.message))
559+
})
560+
```
561+
506562
- #### Handle Referrals
507563

508564
- Referral points are obtained from events triggered by users from rules created on the [Branch Dashboard](https://dashboard.branch.io/referrals/rules)
@@ -598,7 +654,7 @@
598654
<link-domain value="bnc.lt" /> <!-- optional previous link domain -->
599655
<ios-team-release value="PW4Q8885U7" /> <!-- required if iOS app -->
600656
<ios-team-debug value="FG35JLLMXX" /> <!-- optional -->
601-
<android-prefix value="/WSuf" /> <!-- optional (for bnc.lt) -->
657+
<android-prefix value="/WSuf" /> <!-- optional (for bnc.lt and custom domains) -->
602658
<android-testmode value="true" /> <!-- optional (simulate installs) -->
603659
</branch-config>
604660
```
@@ -794,6 +850,215 @@
794850
| $twitter_player_width | | Set the player’s width in pixels
795851
| $twitter_player_height | | Set the player’s height in pixels
796852

853+
- #### Link Data: Commerce Properties
854+
855+
- For [Track Commerce](#track-commerce)
856+
857+
| Value | Category |
858+
| --- | --- |
859+
| 0 | Animals & Pet Supplies |
860+
| 1 | Apparel & Accessories |
861+
| 2 | Arts & Entertainment |
862+
| 3 | Baby & Toddler |
863+
| 4 | Business & Industrial |
864+
| 5 | Camera & Optics |
865+
| 6 | Electronics |
866+
| 7 | Food, Beverage & Tobacco |
867+
| 8 | Furniture |
868+
| 9 | Hardware |
869+
| 10 | Health & Beauty |
870+
| 11 | Home & Garden |
871+
| 12 | Luggage & Bags |
872+
| 13 | Mature |
873+
| 14 | Media |
874+
| 15 | Office Supplies |
875+
| 16 | Religious & Ceremonial |
876+
| 17 | Software |
877+
| 18 | Sporting Goods |
878+
| 19 | Toys & Games |
879+
| 20 | Vehicles & Parts |
880+
881+
| Value | Currency |
882+
| --- | --- |
883+
| 0 | AED |
884+
| 1 | AFN |
885+
| 2 | ALL |
886+
| 3 | AMD |
887+
| 4 | ANG |
888+
| 5 | AOA |
889+
| 6 | ARS |
890+
| 7 | AUD |
891+
| 8 | AWG |
892+
| 9 | AZN |
893+
| 10 | BAM |
894+
| 11 | BBD |
895+
| 12 | BDT |
896+
| 13 | BGN |
897+
| 14 | BHD |
898+
| 15 | BIF |
899+
| 16 | BMD |
900+
| 17 | BND |
901+
| 18 | BOB |
902+
| 19 | BOV |
903+
| 20 | BRL |
904+
| 21 | BSD |
905+
| 22 | BTN |
906+
| 23 | BWP |
907+
| 24 | BYN |
908+
| 25 | BYR |
909+
| 26 | BZD |
910+
| 27 | CAD |
911+
| 28 | CDF |
912+
| 29 | CHE |
913+
| 30 | CHF |
914+
| 31 | CHW |
915+
| 32 | CLF |
916+
| 33 | CLP |
917+
| 34 | CNY |
918+
| 35 | COP |
919+
| 36 | COU |
920+
| 37 | CRC |
921+
| 38 | CUC |
922+
| 39 | CUP |
923+
| 40 | CVE |
924+
| 41 | CZK |
925+
| 42 | DJF |
926+
| 43 | DKK |
927+
| 44 | DOP |
928+
| 45 | DZD |
929+
| 46 | EGP |
930+
| 47 | ERN |
931+
| 48 | ETB |
932+
| 49 | EUR |
933+
| 50 | FJD |
934+
| 51 | FKP |
935+
| 52 | GBP |
936+
| 53 | GEL |
937+
| 54 | GHS |
938+
| 55 | GIP |
939+
| 56 | GMD |
940+
| 57 | GNF |
941+
| 58 | GTQ |
942+
| 59 | GYD |
943+
| 60 | HKD |
944+
| 61 | HNL |
945+
| 62 | HRK |
946+
| 63 | HTG |
947+
| 64 | HUF |
948+
| 65 | IDR |
949+
| 66 | ILS |
950+
| 67 | INR |
951+
| 68 | IQD |
952+
| 69 | IRR |
953+
| 70 | ISK |
954+
| 71 | JMD |
955+
| 72 | JOD |
956+
| 73 | JPY |
957+
| 74 | KES |
958+
| 75 | KGS |
959+
| 76 | KHR |
960+
| 77 | KMF |
961+
| 78 | KPW |
962+
| 79 | KRW |
963+
| 80 | KWD |
964+
| 81 | KYD |
965+
| 82 | KZT |
966+
| 83 | LAK |
967+
| 84 | LBP |
968+
| 85 | LKR |
969+
| 86 | LRD |
970+
| 87 | LSL |
971+
| 88 | LYD |
972+
| 89 | MAD |
973+
| 90 | MDL |
974+
| 91 | MGA |
975+
| 92 | MKD |
976+
| 93 | MMK |
977+
| 94 | MNT |
978+
| 95 | MOP |
979+
| 96 | MRO |
980+
| 97 | MUR |
981+
| 98 | MVR |
982+
| 99 | MWK |
983+
| 100 | MXN |
984+
| 101 | MXV |
985+
| 102 | MYR |
986+
| 103 | MZN |
987+
| 104 | NAD |
988+
| 105 | NGN |
989+
| 106 | NIO |
990+
| 107 | NOK |
991+
| 108 | NPR |
992+
| 109 | NZD |
993+
| 110 | OMR |
994+
| 111 | PAB |
995+
| 112 | PEN |
996+
| 113 | PGK |
997+
| 114 | PHP |
998+
| 115 | PKR |
999+
| 116 | PLN |
1000+
| 117 | PYG |
1001+
| 118 | QAR |
1002+
| 119 | RON |
1003+
| 120 | RSD |
1004+
| 121 | RUB |
1005+
| 122 | RWF |
1006+
| 123 | SAR |
1007+
| 124 | SBD |
1008+
| 125 | SCR |
1009+
| 126 | SDG |
1010+
| 127 | SEK |
1011+
| 128 | SGD |
1012+
| 129 | SHP |
1013+
| 130 | SLL |
1014+
| 131 | SOS |
1015+
| 132 | SRD |
1016+
| 133 | SSP |
1017+
| 134 | STD |
1018+
| 135 | SYP |
1019+
| 136 | SZL |
1020+
| 137 | THB |
1021+
| 138 | TJS |
1022+
| 139 | TMT |
1023+
| 140 | TND |
1024+
| 141 | TOP |
1025+
| 142 | TRY |
1026+
| 143 | TTD |
1027+
| 144 | TWD |
1028+
| 145 | TZS |
1029+
| 146 | UAH |
1030+
| 147 | UGX |
1031+
| 148 | USD |
1032+
| 149 | USN |
1033+
| 150 | UYI |
1034+
| 151 | UYU |
1035+
| 152 | UZS |
1036+
| 153 | VEF |
1037+
| 154 | VND |
1038+
| 155 | VUV |
1039+
| 156 | WST |
1040+
| 157 | XAF |
1041+
| 158 | XAG |
1042+
| 159 | XAU |
1043+
| 160 | XBA |
1044+
| 161 | XBB |
1045+
| 162 | XBC |
1046+
| 163 | XBD |
1047+
| 164 | XCD |
1048+
| 165 | XDR |
1049+
| 166 | XFU |
1050+
| 167 | XOF |
1051+
| 168 | XPD |
1052+
| 169 | XPF |
1053+
| 170 | XPT |
1054+
| 171 | XSU |
1055+
| 172 | XTS |
1056+
| 173 | XUA |
1057+
| 174 | XXX |
1058+
| 175 | YER |
1059+
| 176 | ZAR |
1060+
| 177 | ZMW |
1061+
7971062
- #### Compiling: Cordova Dependencies
7981063

7991064
- Node
@@ -910,7 +1175,7 @@
9101175

9111176
```xml
9121177
<!-- config.xml -->
913-
<plugin name="branch-cordova-sdk" spec="^2.5.0" />
1178+
<plugin name="branch-cordova-sdk" spec="^2.6.0" />
9141179
```
9151180

9161181
- #### Compiling: Incompatible Plugins

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "branch-cordova-sdk",
33
"description": "Branch Metrics Cordova SDK",
44
"main": "www/branch.js",
5-
"version": "2.5.17",
5+
"version": "2.6.0",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",

plugin.template.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="2.5.17">
27+
version="2.6.0">
2828

2929
<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->
3030

@@ -69,6 +69,7 @@ SOFTWARE.
6969
<config-file target="config.xml" parent="/*">
7070
<feature name="BranchSDK">
7171
<param name="ios-package" value="BranchSDK" />
72+
<param name="onload" value="true" />
7273
</feature>
7374
</config-file>
7475

plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="2.5.17">
27+
version="2.6.0">
2828

2929
<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->
3030

@@ -69,6 +69,7 @@ SOFTWARE.
6969
<config-file target="config.xml" parent="/*">
7070
<feature name="BranchSDK">
7171
<param name="ios-package" value="BranchSDK" />
72+
<param name="onload" value="true" />
7273
</feature>
7374
</config-file>
7475

-238 KB
Binary file not shown.
244 KB
Binary file not shown.

0 commit comments

Comments
 (0)