Docs
/
sensor
/
Application Analytics for Conviva JavaScript Sensor
Application Analytics for Conviva JavaScript Sensor
Use Application Analytics to autocollect events, track application specific events and state changes, and track users anonymously.
Updated 2026-05-29
·
application, analytics, sensor developer center, sensor integration, javascript, application analytics
Use Application Analytics to autocollect events, track application specific events and state changes, and track users anonymously.
Download
To use the video sensor, download the Core JavaScript SDK file (version 4.5.6 or above) from Conviva JavaScript Sensor Integration and unzip the downloaded file.
To use the application sensor, use the latest DPI sensor .
Initialization
Add the tracking script to your website
Add the following script to the HTML head section of your website:
<script type="text/javascript">
(function(p, i) {
if (!p[i]) {
p.GlobalConvivaNamespace = p.GlobalConvivaNamespace || [];
p.GlobalConvivaNamespace.push(i);
p[i] = function() {
(p[i].q = p[i].q || []).push(arguments)
};
p[i].q = p[i].q || [];
}
}(window, "apptracker"));
</script>
#### include convivaAppTracker.js as script tag.
<script src= "<<URL / Path to convivaAppTracker.js>>"></script>
Initialize the tracker
window.apptracker('convivaAppTracker', {
appId: '{{YOUR_APP_ID_ADVISED_BY_Conviva}}',
convivaCustomerKey: '{{YOUR_CUSTOMER_KEY_ADVISED_BY_Conviva}}',
contexts: {
performanceTiming: true,
},
});
Set the user id (viewer id)
// Set this after initializing the tracker and before autocollection
window.apptracker('setUserId','replace_me_by_the_userId');
Set the user id (viewer id) before autocollection, so that it is applied across all the events that are enabled for auto-collection.
Enable autocollection
window.apptracker('enableLinkClickTracking');
window.apptracker('enableButtonClickTracking');
Enable anonymous tracking
To enable anonymous tracking for the users opting out, use the following API:
apptracker('enableAnonymousTracking', { withServerAnonymisation: true });
apptracker('clearUserData'); // Optionally clear client side cookies
Alternatively, you could also enable anonymous tracking using the following parameter:
apptracker('convivaAppTracker', {
appId: '{{YOUR_APP_ID_ADVISED_BY_Conviva}}',
convivaCustomerKey: '{{YOUR_CUSTOMER_KEY_ADVISED_BY_Conviva}}'
anonymousTracking: { withServerAnonymisation: true },
stateStorageStrategy: "none",
contexts: {
performanceTiming: true
}
});
To re-enable normal tracking, use the following API:
apptracker('disableAnonymousTracking', 'cookieAndLocalStorage');
Enable Error Tracking
To enable automatic tracking of run-time exceptions in the application, use the following API:
window.apptracker('enableErrorTracking');
Alternatively, you could report exceptions manually using the following API:
apptracker('trackError', {
message: 'Cannot get user object',
filename: 'shop.js',
error: exceptionObj //Exception object containing properties describing the exception.
});
Custom event tracking to track your application specific events and state changes
Use trackCustomEvent() API to track all kinds of events. This API provides 2 fields to describe the tracked events.
The following example shows the implementation of the 'onClick' event listener to any element.
let custom_data = "{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}"
tracker('trackCustomEvent', {
name: "custom_event_name",
data: custom_data
});