-
Notifications
You must be signed in to change notification settings - Fork 16
/
track.html
57 lines (47 loc) · 1.94 KB
/
track.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
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voucherify Track Event</title>
</head>
<body>
<form id="trackForm">
<fieldset>
<legend>Track Event</legend>
<p><label>Favorite superhero?</label>
<input type="text" name="code" id="superhero">
</p>
<p><input type="submit" name="submit" value="Save"></p>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qs/6.5.1/qs.min.js" crossorigin></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/@voucherify/[email protected]/dist/voucherifysdk.umd.production.min.js" crossorigin></script>
<script>
const voucherify = VoucherifySDK.VoucherifyClientSide({
clientApplicationId: "158106cb-c95a-42e8-bc73-01ba34e2e756",
clientSecretKey: "c84aaea9-9f4a-47b3-a49f-4a5c4bd37964",
origin: "example.com"
});
voucherify.setIdentity("[email protected]");
const trackEvent = (e) => {
e.preventDefault();
const favSuperhero = document.getElementById("superhero").value;
const metadata = {
superhero: favSuperhero
}
voucherify
.track('Custom event 123', customer, metadata)
.then(result => {
console.log(result)
})
.catch(console.error)
};
document
.getElementById("trackForm")
.addEventListener("submit", trackEvent, false);
</script>
</body>
</html>