ibmmfpfanalytics
The IBM® MobileFirst® web analytics client API provides the ability to enable, disable and log custom events, and to send them to the MobileFirst server.
The data collected via this API is then available in the IBM MobileFirst Analytics Console (Apps -> Client Log Search).
The user calls the send
method in order to deliver the analytics to the server. In case of an unhandled JavaScript error, analytics data is sent automatically.
ibmmfpfanalytics
is implemented as UMD JavaScript module. This means it can be consumed as a separate AMD module with require.js
, or used under the global context.
Usage as AMD module, with 'define':
define([
'ibmmfpfanalytics'
], function(ibmmfpfanalytics){
ibmmfpfanalytics.send();
}
);
Usage with global context:
Field Attributes | Field Name and Description |
---|---|
IBM® MobileFirst® logger object that facilitates logging to the IBM MobileFirst server at all levels.
|
Method Attributes | Method Name and Description |
---|---|
addEvent(event)
Submits custom event data (JSON object), events later can be processed and reported.
|
|
enable(flag)
Sets the enablement flag for data collection. |
|
enableAutoSend(autoSend)
Enable/Disable the Auto Send Logs feature.
|
|
init(deviceID, appName, contextRoot)
Initializes the |
|
send()
Send all analytics data collected up to this point to the IBM MobileFirst server.
|
|
setUserContext(usedId)
Specify current application user.
|
|
state()
Gets the current state of the
ibmmfpfanalytics instance. |
ibmmfpfanalytics.addEvent({'Purchases':'radio'});
ibmmfpfanalytics.addEvent({'src':'App landing page','target':'About page'});
Sets the enablement flag for data collection.
send()
call).
ibmmfpfanalytics.enable(true);
enableAutoSend(true);
Initializes the ibmmfpfanalytics
.
ibmmfpfanalytics.init('device-uuid-12345', 'application1', 'mfp');
ibmmfpfanalytics.send()
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
unsetUserContext
method. The user session ends after 30 minutes of inactivity,
unless another call is made to setUserContext(used)
.
If your application supports user profiles, call this method when the user
profile changes.
ibmmfpfanalytics.setUserContext();
ibmmfpfanalytics
instance.
ibmmfpfanalytics
.ibmmfpfanalytics.state();