You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 2012-2014 Snowplow Analytics Ltd. All rights reserved.
6
+
*
7
+
* Redistribution and use in source and binary forms, with or without
8
+
* modification, are permitted provided that the following conditions are
9
+
* met:
10
+
*
11
+
* * Redistributions of source code must retain the above copyright
12
+
* notice, this list of conditions and the following disclaimer.
13
+
*
14
+
* * Redistributions in binary form must reproduce the above copyright
15
+
* notice, this list of conditions and the following disclaimer in the
16
+
* documentation and/or other materials provided with the distribution.
17
+
*
18
+
* * Neither the name of Anthon Pang nor Snowplow Analytics Ltd nor the
19
+
* names of their contributors may be used to endorse or promote products
20
+
* derived from this software without specific prior written permission.
21
+
*
22
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
*/
34
+
35
+
define([
36
+
"intern!object",
37
+
"intern/chai!assert",
38
+
"intern/dojo/node!../lib/core.js",
39
+
"intern/dojo/node!JSON"
40
+
],function(registerSuite,assert,core,JSON){
41
+
42
+
vartracker=core(false);
43
+
44
+
registerSuite({
45
+
name: "Tracking events",
46
+
"Track a page view": function(){
47
+
varurl='http://www.example.com';
48
+
varpage='title page';
49
+
varexpected={
50
+
e: 'pv',
51
+
url: url,
52
+
page: page
53
+
};
54
+
assert.deepEqual(tracker.trackPageView(url,page),expected,'A page view should be tracked correctly');
55
+
},
56
+
57
+
"Track a page ping": function(){
58
+
varurl='http://www.example.com';
59
+
varreferer='http://www.google.com';
60
+
varexpected={
61
+
e: 'pp',
62
+
url: url,
63
+
refr: referer
64
+
};
65
+
66
+
assert.deepEqual(tracker.trackPagePing(url,null,referer),expected,'A page ping should be tracked correctly');
67
+
},
68
+
69
+
"Track a structured event": function(){
70
+
varexpected={
71
+
e: 'se',
72
+
se_ca: 'cat',
73
+
se_ac: 'act',
74
+
se_la: 'lab',
75
+
se_pr: 'prop',
76
+
se_va: 'val'
77
+
};
78
+
79
+
assert.deepEqual(tracker.trackStructEvent('cat','act','lab','prop','val'),expected,'A structured event should be tracked correctly');
80
+
},
81
+
82
+
"Track an ecommerce transaction event": function(){
83
+
varorderId='ak0008';
84
+
vartotalValue=50;
85
+
vartaxValue=6;
86
+
varshipping=0;
87
+
varcity='Phoenix';
88
+
varstate='Arizona';
89
+
varcountry='USA';
90
+
varcurrency='USD';
91
+
varexpected={
92
+
e: 'tr',
93
+
tr_tt: totalValue,
94
+
tr_tx: taxValue,
95
+
tr_id: orderId,
96
+
tr_sh: shipping,
97
+
tr_ci: city,
98
+
tr_st: state,
99
+
tr_co: country,
100
+
tr_cu: currency
101
+
};
102
+
103
+
assert.deepEqual(tracker.trackEcommerceTransaction(orderId,totalValue,null,taxValue,shipping,city,state,country,currency),expected,'A transaction event should be tracked correctly');
0 commit comments