Skip to content

Commit ede6b34

Browse files
committed
Improved examples in README and added link to wiki page
1 parent 0461e12 commit ede6b34

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

core/README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
1919
var 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
2525
coreInstance.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');
3133
coreInstance.setUserId('user-321');
3234
coreInstance.setColorDepth(24);
3335
coreInstance.setViewport(600, 400);
@@ -38,15 +40,19 @@ var pageViewPayload = coreInstance.trackPageView('http://www.example.com', 'land
3840
console.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
100108
coreInstance.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

105117
The 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

Comments
 (0)