Prime Data - Web JS SDK
Prime Data - JS SDK tracking event
Prime Data Web Tracker Javascript Library
This is the web tracker for apache-unomi ( http://unomi.apache.org/ )
This package can be used in a Javascript application to interact with Prime Data.
Getting started
Adds tracker to your app :
yarn add primedata-js-sdk
Then
follower.initialize({
'Prime Data': {
scope: 'my-app',
url: 'http://unomi:8181',
}
});
follower.ready(function() {
console.log("Unomi context loaded - profile id : "+window.cxs.profileId + ", sessionId="+window.cxs.sessionId);
});
Implicit page view event
In the initialize call, the tracker will generate an implicit page view event, which by default will be populated with the following information:
window.digitalData.page = window.digitalData.page || {
path: location.pathname + location.hash,
pageInfo: {
pageName: document.title,
pageID : location.pathname + location.hash,
pagePath : location.pathname + location.hash,
destinationURL: location.href
}
}
Now if you want to provide your own custom page information for the initial page view, you can simply do it like this:
follower.initialize({
scope: 'myScope',
url: 'http://unomi:8181', // we use an empty URL to make it relative to this page.
initialPageProperties: {
path: path,
pageInfo: {
destinationURL: location.href,
tags: ["tag1", "tag2", "tag3"],
categories: ["category1", "category2", "category3"]
},
interests: {
"interest1": 1,
"interest2": 2,
"interest3": 3
}
}
});
Also note that the FIRST call to follower.page() will be IGNORED because of this initial page view. This is the way that the Analytics.js library handles it. So make sure you are aware of this when calling it. This is to avoid having two page views on a single call and to be compatible with old versions that did use the explicit call.
Sending events
Here are some examples of sending events :
follower.page() // first call will be ignored as the initial page load is done in the initialize method
follower.identify("af285fa381f77778ec427c01d48764b863c14705", {
phone_number: '0985490107',
full_name: 'Nguyen Le Phong',
email: 'nguyenlephong@primedata.ai'
});
follower.track('page_viewed', {
title: 'How to Create a Tracking Plan',
course: 'Intro to PrimeData CDXP'
});
As the PrimeData Tracker uses the Analytics.JS API, you can find more information about it here.
All methods can be used on follower
object, although not all event types are supported by PrimeData integration.