There are 3 ways how to collect events to Persoo. We recommend to use Data Layer.
- using Persoo() js function to send an event
- using Data Layer push() function
- using REST API directly (without js client, which makes your life easier) … you will have to implement browserID generation and GDPR policies on the server side.
1. Through data layer (the recommended way)
Persoo works in a similar way like standard Google dataLayer, but requires different data to be sent.
Example:
1 2 3 4 5 6 7 8 |
var persooDataLayer=[] persooDataLayer.push({ paramA: valueA, paramB: valueB, ... paramZ: valueZ, event: 'pageview' // this will automatically send event with the data from persooDataLayer }); |
If you push an event into the Data Layer:
1 |
persooDataLayer.push({'event': 'event_name', param: value,...}); |
Then it will be automatically sent to a Persoo server as a new event.
Persoo sends a default pageView
event when it loads (this can be disabled for options below).
2. By manual event call
1 |
persoo('send', 'eventName', {paramA:valueA,...,paramZ:valueZ}, callback); |
1 |
persoo('send','addToBasket',{itemID: 'DKE6548', pageType: 'basket'}); |
If the data is prepared in one or more objects, you can send them as follows:
1 2 3 4 5 6 7 8 |
var data={ paramA: valueA, paramB: valueB, ... paramZ: valueZ } var data2={}; persoo('send', 'pageview', data, data2); |
Where the data from variables “data” and “data2” are merged together.
3. Through REST API
If you don’t want to use a JS client (e.g. to avoid CORS problems), you can make your request through RTP API.
Note: but do not use it for all events/pageviews reporting, otherwise you will have to develop your self all the things related to BrowserID cookies, profile data collection levels, et.c