forked from aleross/angular-segment-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
56 lines (46 loc) · 1.83 KB
/
example.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
<!DOCTYPE html>
<html ng-app="example">
<head>
<title>ngSegment Example</title>
<!-- Angular -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
<!-- ngSegment -->
<script src="segment.min.js"></script>
<!-- Example Angular application -->
<script>
// Provider configuration
angular.module('example', ['ngSegment']).config(function (segmentProvider, ExampleEvents) {
segmentProvider.setDebug(true).setEvents(ExampleEvents);
segmentProvider.track('test');
});
// Events constant example. This is optional.
angular.module('example').constant('ExampleEvents', {
TEST_EVENT: 'Test Event'
});
angular.module('example').constant('segmentConfig', {
debug: true,
apiKey: '[YOUR KEY]'
});
// Service configuration and usage
angular.module('example').controller('ExampleController', function ($scope, segment, segmentLoader) {
segment.track('controller test');
$scope.test = function () {
segment.track(segment.events.TEST_EVENT, { foo: 'bar' });
};
// segmentLoader.load(segment.config.apiKey);
});
</script>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>
<body ng-controller="ExampleController">
<div class="jumbotron">
<div class="container">
<h1>Example</h1>
</div>
</div>
<div class="container">
<button class="btn btn-primary" ng-click="test()">Test</button>
</div>
</body>
</html>