@@ -18,16 +18,18 @@ var core = require('snowplow-tracker-core');
1818// Create an instance with base 64 encoding set to false (it defaults to true)
1919var coreInstance = core (false );
2020
21- // Add this name-value pair to all payloads
22- coreInstance .addPayloadPair (' dtm ' , new Date (). getTime () );
21+ // Add a name-value pair to all payloads
22+ coreInstance .addPayloadPair (' vid ' , 2 );
2323
24- // Add each name-value pair in this dictionary to all payloads
24+ // Add each name-value pair in a dictionary to all payloads
2525coreInstance .addPayloadDict ({
26- ' p ' : ' web ' , // platform
27- ' tv ' : ' js-3.0.0 ' // tracker version
26+ ' ds ' : ' 1160x620 ' ,
27+ ' fp ' : 4070134789
2828});
2929
3030// Add name-value pairs to all payloads using convenience methods
31+ coreInstance .setTrackerVersion (' js-3.0.0' );
32+ coreInstance .setPlatform (' web' );
3133coreInstance .setUserId (' user-321' );
3234coreInstance .setColorDepth (24 );
3335coreInstance .setViewport (600 , 400 );
@@ -38,15 +40,19 @@ var pageViewPayload = coreInstance.trackPageView('http://www.example.com', 'land
3840console .log (pageViewPayload);
3941/*
4042{
41- 'tv': 'js-2.0.0',
42- 'p': 'web',
43- 'dtm': 1406879959702,
4443 'e': 'pv',
4544 'url': 'http://www.example.com',
4645 'page': 'landing page',
4746 'uid': 'user-321',
47+ 'vd': 2,
48+ 'ds': '1160x620',
49+ 'fp': 4070134789
50+ 'tv': 'js-3.0.0',
51+ 'p': 'web',
4852 'cd': 24,
49- 'vp': 600x400
53+ 'vp': '600x400',
54+ 'dtm': 1406879959702, // timestamp
55+ 'eid': '0718a85a-45dc-4f71-a949-27870442ed7d' // UUID
5056}
5157*/
5258
@@ -75,7 +81,9 @@ console.log(unstructEventPayload);
7581 'elementId': 'bannerLink'
7682 }
7783 }
78- }
84+ },
85+ 'dtm': 1406879973439,
86+ 'eid': '956c6670-cbf6-460b-9f96-143e0320fdf6'
7987}
8088*/
8189```
@@ -100,6 +108,10 @@ var coreInstance = core(); // Base 64 encoding on by default
100108coreInstance .setBase64Encoding (false ); // Base 64 encoding is now off
101109```
102110
111+ ## Documentation
112+
113+ For more information on the Snowplow JavaScript Tracker Core's API, view its [ wiki page] [ wiki ] .
114+
103115## Copyright and license
104116
105117The Snowplow JavaScript Tracker Core is copyright 2014 Snowplow Analytics Ltd.
@@ -117,3 +129,4 @@ limitations under the License.
117129
118130[ npm-url ] : http://badge.fury.io/js/snowplow-tracker-core
119131[ npm-image ] : https://badge.fury.io/js/snowplow-tracker-core.svg
132+ [ wiki ] : https://github.com/snowplow/snowplow/wiki/Javascript-Tracker-Core
0 commit comments