E Legacy Analytics API
This chapter provides documentation for the legacy Analytics API.
Enabling Your Mobile Apps to Report Event Data
With the legacy analytics features, OMCe creates analytics reports from information conveyed in JSON payloads. The calls that deliver the JSON payload to the Analytics API, which records event data, can be either straight REST calls or REST calls made through the client SDK for your mobile platform. In either case, OMCe uploads and stores the JSON payload and then graphs it in a report.
Describing Analytics Events in JSON
The JSON payload describes the context for mobile app users in terms of both their mobile devices and the events that track user interactions. These types of events are known as custom events. A JSON payload has one or more of these custom events, and is also constructed from a context event that provides user and system details, a start session event, and end session event. The custom events are grouped within the session events to describe an analytic session.
Note:
The client SDK tracks analytic sessions on a file system, which means that a file grows as you add more events to a session. The MAF MCS Utility, which allows mobile apps built using Oracle Mobile Application Framework (MAF) to access OMCe, enables sessions to be saved in memory. However, saving sessions in memory might degrade memory consumption when there are a large number of custom events (say, more than 1000). Consequently, you might lose some event logging, because the mobile app may crash before it can post events to OMCe. See MAF MCS Utility Developer Guide.Taking a Look at the JSON Payload
-
A
name
of fewer than 100 characters. -
A unique string defined for the
sessionID
property, which associates an event with a particular session. If you create your own JSON, you must assign a unique string to this property. The SDK ensures uniqueness by adding a text string punctuated by hyphens known as a Universally Unique Identifier (UUID). -
A time stamp: Events are ordered by time stamp (though not strictly, because events can share the same time stamp). The client SDK generates the time stamp automatically.
[
{
"name":"context",
"type":"system",
"timestamp":"2013-04-12T23:20:54.345Z",
"properties":{
"userName":"jimSmith",
"model":"iPhone5,1",
"longitude":"-122.11663",
"latitude":"37.35687",
"timezone":"-14400",
"manufacturer":"Apple",
"osName":"iPhone OS",
"osVersion":"7.1",
"osBuild":"13E28",
"carrier":"AT&T"
}
},
{
"name":"sessionStart",
"type":"system",
"timestamp":"2013-04-12T23:20:55.052Z",
"sessionID":"2d64d3ff-25c7-4b92-8e49-21884b3495ce"
},
{
"name":"PurchaseFailed",
"type":"custom",
"timestamp":"2013-04-12T23:20:56.523Z",
"sessionID":"2d64d3ff-25c7-4b92-8e49-21884b3495ce",
"properties":{
"cartContent":"WIDGET",
"cartPrice":"$50,000"
}
{
"name":"sessionEnd",
"type":"system",
"timestamp":"2013-04-12T23:25:55.052Z",
"sessionID":"2d64d3ff-25c7-4b92-8e49-21884b3495ce"
}
]
Every JSON payload must begin with a context event. In the preceding example, this event is indicated by "name":"context"
and includes properties that describe the current context of the mobile app, such as user name and the longitude and latitude. The context event is associated with each event that follows it, such as the session start and end events that demarcate a session. It is also associated with events raised in the mobile app code, such as PurchaseFailed
in the preceding example.
Note:
Although you can add this context to events using straight REST calls, the client SDK adds both session and device context information to the payload automatically.Creating Your Own JSON Payload
-
Start each payload with a context event (indicated by
"name":"context"
). -
Add a context event whenever the device's context changes — typically when the
longitude
,latitude
, orusername
properties need to change. -
You can randomly add the events within the payloads, but you must associate every event raised in the mobile app code with
sessionStart
andsessionEnd
events just likePurchaseFailed
in the preceding example, as noted by“type”:”custom”
.Note:
Ensure that these events share the samesessionID
value. When events have the samesessionID
value, the OMCe server can approximate the session even if part of the payload (like theendSession
definition) isn’t recorded by the database.
How the Client SDK Fits In
You can enable analytics for an app through OMCe’s client SDK for the app’s platform. Each client SDK has a configuration file where you can enable analytics either for the mobile backend that the app is using for the OMCe analytics app that it specifies.
The client SDK:
-
Automatically defines the start and end of sessions and manages them using the UUIDs that it assigns to the
sessionID
property. -
Adds the context event at the beginning of each payload.
-
Adds such device properties as the
username
,latitude
, andlongitude
for context events.Note:
On the server, thelongitude
andlatitude
values are translated into city, country, postal code, and street. -
Marks events raised in mobile app code as
custom
orsystem
for session or context events. It also adds atimeStamp
to each event.
For specifics on each platform, see:
Adding Location Properties to the context
Event
The Oracle eLocation Service (maps.oracle.com) derives location from the longitude
and latitude
properties in the JSON request body. These properties only work if your mobile apps are used in countries where Oracle eLocation Service is available. For countries where Oracle eLocation Services is unavailable, you can still enable OMCe to record the location data that allows countries to display in the Dashboard map by adding location-related properties to the context
event.
context
event:
-
locality
— The mobile device's locality, such as city, township, or village. -
region
— The mobile device's region, such as state, canton, or province. -
postalCode
— The mobile device’s postal code. -
country
— The mobile device’s GPS country. For some countries in the Asia-Pacific region, you can use a two-letter identifier, such as JP (Japan), CN (China), or KR (South Korea).
Note:
Do not includelongitude
and latitude
in the context
event if you define any of these properties.
{
"name":"context",
"type":"system",
"timestamp":"2013-04-12T23:23:34.345Z",
"properties":{
"userName":"GDoe321",
"locality":"Aomi",
"region":"Kanto",
"postalCode":"135-0064",
"country":"JP",
"timezone":"-14400",
"carrier":"AT&T",
"model":"iPhone5,1",
"manufacturer":"Apple",
"osName":"iPhone OS",
"osVersion":"7.1",
"osBuild":"13E28"
}