-
Notifications
You must be signed in to change notification settings - Fork 133
/
amplitudejs-requirejs.html
79 lines (75 loc) · 3.49 KB
/
amplitudejs-requirejs.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html>
<!--<script src="src/amplitude-snippet.js" type="text/javascript"></script>-->
<script src='require.js' type='text/javascript'></script>
<script>
requirejs.config({
paths: {
'amplitude': '/amplitude'
}
});
require(['amplitude'], function(amplitude) {
amplitude.init('a2dbce0e18dfe5f8e74493843ff5c053', null, {includeReferrer: true}, function() {
alert(amplitude.options.deviceId);
});
window.amplitude = amplitude;
});
var setUserId = function() {
var userId = prompt('Input userId', 'user01');
amplitude.setUserId(userId);
};
var setEventUploadThreshold = function() {
var eventUploadThreshold = parseInt(prompt('Input eventUploadThreshold', 5));
amplitude.options.eventUploadThreshold = eventUploadThreshold;
};
var logEvent = function() {
var event = prompt('Input event type', 'clicked');
amplitude.logEvent(event);
};
var setCity = function() {
var city = prompt('Input city', 'San Francisco, CA');
amplitude.setUserProperties({city: city});
};
var addToPhotoCount = function() {
var photoCount = parseInt(prompt('Input amount to increment photo count by', '2'), 10);
amplitude.identify(new amplitude.Identify().add('photoCount', photoCount));
};
var clickOnLinkA = function() {
amplitude.logEvent('Clicked on link A', null, function() { window.location='https://www.google.com'; });
};
var setPhotoCount = function() {
var photoCount = parseInt(prompt('Input photo count to set', '2'), 10);
amplitude.identify(new amplitude.Identify().set('photoCount', photoCount));
};
var setOncePhotoCount = function() {
var photoCount = parseInt(prompt('Input photo count to setOnce', '2'), 10);
amplitude.identify(new amplitude.Identify().setOnce('photoCount', photoCount));
};
</script>
<script>
require(['amplitude'], function(amplitude) {
amplitude.logEvent('Page loaded');
});
</script>
<body>
<h3>Amplitude JS Test with RequireJS</h3>
<ul>
<li><a href="javascript:setUserId();">Set user ID</a></li>
<li><a href="javascript:amplitude.setOptOut(!amplitude.options.optOut);">Toggle opt out</a></li>
<li><a href="javascript:logEvent();">Log event</a></li>
<li><a href="javascript:amplitude.logEvent('clicked button', {color: 'red;', shape: 'triangle', sides: 3});">Log
event with event properties</a></li>
<li><a href="javascript:amplitude.setUserProperties({age: 30, city: 'San Francisco, CA'});">Set user properties</a></li>
<li><a href="javascript:amplitude.options.batchEvents = !amplitude.options.batchEvents;">Toggle batch events</a></li>
<li><a href="javascript:setEventUploadThreshold();">Set event upload threshold</a></li>
<li><a href="javascript:clickOnLinkA();">Click on link A</a></li>
<br><br>Testing Identify calls<br>
<li><a href="javascript:addToPhotoCount();">Add to photo count</a></li>
<li><a href="javascript:amplitude.identify(new amplitude.Identify().unset('photoCount'));">Unset photo count</a></li>
<li><a href="javascript:setPhotoCount();">Set photo count</a></li>
<li><a href="javascript:setOncePhotoCount();">Set photo count once</a></li>
<li><a href="javascript:setCity();">Set city via setUserProperties</a></li>
<li><a href="javascript:amplitude.clearUserProperties();">Clear all user properties</a></li>
<br><br>
<li><a href="/test/browser/amplitudejs2.html">Go to second page</a></li>
</body>
</html>