|
| 1 | +<html> |
| 2 | +<!--<script src="src/amplitude-snippet.js" type="text/javascript"></script>--> |
| 3 | +<script src='require.js' type='text/javascript'></script> |
| 4 | +<script> |
| 5 | + requirejs.config({ |
| 6 | + paths: { |
| 7 | + 'amplitude': 'https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.9.0-min.gz' |
| 8 | + } |
| 9 | + }); |
| 10 | + |
| 11 | + require(['amplitude'], function(amplitude) { |
| 12 | + amplitude.init('a2dbce0e18dfe5f8e74493843ff5c053', null, {includeReferrer: true}, function() { |
| 13 | + alert(amplitude.options.deviceId); |
| 14 | + }); |
| 15 | + |
| 16 | + window.amplitude = amplitude; |
| 17 | + }); |
| 18 | + |
| 19 | + var setUserId = function() { |
| 20 | + var userId = prompt('Input userId', 'user01'); |
| 21 | + amplitude.setUserId(userId); |
| 22 | + }; |
| 23 | + var setEventUploadThreshold = function() { |
| 24 | + var eventUploadThreshold = parseInt(prompt('Input eventUploadThreshold', 5)); |
| 25 | + amplitude.options.eventUploadThreshold = eventUploadThreshold; |
| 26 | + }; |
| 27 | + var logEvent = function() { |
| 28 | + var event = prompt('Input event type', 'clicked'); |
| 29 | + amplitude.logEvent(event); |
| 30 | + }; |
| 31 | + var setCity = function() { |
| 32 | + var city = prompt('Input city', 'San Francisco, CA'); |
| 33 | + amplitude.setUserProperties({city: city}); |
| 34 | + }; |
| 35 | + var addToPhotoCount = function() { |
| 36 | + var photoCount = parseInt(prompt('Input amount to increment photo count by', '2'), 10); |
| 37 | + amplitude.identify(new amplitude.Identify().add('photoCount', photoCount)); |
| 38 | + }; |
| 39 | + var clickOnLinkA = function() { |
| 40 | + amplitude.logEvent('Clicked on link A', null, function() { window.location='https://www.google.com'; }); |
| 41 | + }; |
| 42 | + var setPhotoCount = function() { |
| 43 | + var photoCount = parseInt(prompt('Input photo count to set', '2'), 10); |
| 44 | + amplitude.identify(new amplitude.Identify().set('photoCount', photoCount)); |
| 45 | + }; |
| 46 | + var setOncePhotoCount = function() { |
| 47 | + var photoCount = parseInt(prompt('Input photo count to setOnce', '2'), 10); |
| 48 | + amplitude.identify(new amplitude.Identify().setOnce('photoCount', photoCount)); |
| 49 | + }; |
| 50 | +</script> |
| 51 | +<script> |
| 52 | + require(['amplitude'], function(amplitude) { |
| 53 | + amplitude.logEvent('Page loaded'); |
| 54 | + }); |
| 55 | +</script> |
| 56 | + |
| 57 | +<body> |
| 58 | +<h3>Amplitude JS Test with RequireJS</h3> |
| 59 | +<ul> |
| 60 | + <li><a href="javascript:setUserId();">Set user ID</a></li> |
| 61 | + <li><a href="javascript:amplitude.setOptOut(!amplitude.options.optOut);">Toggle opt out</a></li> |
| 62 | + <li><a href="javascript:logEvent();">Log event</a></li> |
| 63 | + <li><a href="javascript:amplitude.logEvent('clicked button', {color: 'red;', shape: 'triangle', sides: 3});">Log |
| 64 | + event with event properties</a></li> |
| 65 | + <li><a href="javascript:amplitude.setUserProperties({age: 30, city: 'San Francisco, CA'});">Set user properties</a></li> |
| 66 | + <li><a href="javascript:amplitude.options.batchEvents = !amplitude.options.batchEvents;">Toggle batch events</a></li> |
| 67 | + <li><a href="javascript:setEventUploadThreshold();">Set event upload threshold</a></li> |
| 68 | + <li><a href="javascript:clickOnLinkA();">Click on link A</a></li> |
| 69 | + <br><br>Testing Identify calls<br> |
| 70 | + <li><a href="javascript:addToPhotoCount();">Add to photo count</a></li> |
| 71 | + <li><a href="javascript:amplitude.identify(new amplitude.Identify().unset('photoCount'));">Unset photo count</a></li> |
| 72 | + <li><a href="javascript:setPhotoCount();">Set photo count</a></li> |
| 73 | + <li><a href="javascript:setOncePhotoCount();">Set photo count once</a></li> |
| 74 | + <li><a href="javascript:setCity();">Set city via setUserProperties</a></li> |
| 75 | + <li><a href="javascript:amplitude.clearUserProperties();">Clear all user properties</a></li> |
| 76 | + <br><br> |
| 77 | + <li><a href="/test/browser/amplitudejs2.html">Go to second page</a></li> |
| 78 | +</body> |
| 79 | +</html> |
0 commit comments