Close

Applications - SDK

In order to integrate your application to send event data to Omniata, there are a few things that need to be set up on Omniata platform first:

  1. Installing a Project
    • Project will define how to process and transform the event data
    • Install by going to the Omniata main page, select 'New Project' , and install a 'Custom Project'
  2. Creating an Application
    • Typically per application and per platform, for example 'My App (iOS)'
    • Auto-generates API keys connecting the event data stream and Project
    • API keys can be found with the Custom Project under Data Model > API Keys

Overview of Omniata SDKs

To make application integration easier, Omniata provides ready-made SDKs to use the Event API and Channel API for a number of platforms. Application developers are strongly encouraged to use these SDKs instead of using their own custom implementation.

The high-level features of the SDKs are:

Event API

  • Easy sending of Omniata events and support for sending custom events
  • Non-blocking application call
  • Persistent event storage
  • Network reachability check
  • SSL connections
  • Retry mechanism
  • Automatic parameters used for user segmenting

Channel API

  • Sending Channel API calls and asynchronously receiving the content
  • SSL connections
  • Please access the SDKs and related documentation from the links below.
SDK Download Documentation Other
Android Android SDK 2.1.13 API details source code
iOS iOS SDK 2.2.7 API Details source code
Unity Unity3D plugin 1.3.22 API Details

source code with example project

PHP PHP SDK 1.0.0
JavaScript

snippet.js
snippet.min.js

Android SDK

Features and Technical Description

The SDK code is in the com.omniata.android.sdk package, and there are 10 classes inside of the package altogether.
The SDK logs using android.util.Log. It has internal log level setting, which defaults to Log.ASSERT. The log level can be changed using setLogLevel().

Event API

The SDK automatic adds Event Parameters in om_load-events:

  • om_device: the device model, android.os.Build.MODEL
  • om_platform: the platform, 'android'
  • om_os_version: the version of the operating system, in Android SDK obtained using SystemInfo.operatingSystem;
  • om_sdk_version: the version of the SDK
  • om_android_id: Settings.Secure.ANDROID_ID
  • om_android_serial: android.os.Build.SERIAL
  • om_android_device: android.os.Build.DEVICE
  • om_android_hardware: android.os.Build.HARDWARE
  • om_package_version_code: getPackageManager().getPackageInfo(getPackageName(),0).versionCode
  • om_package_version_name: getPackageManager().getPackageInfo(getPackageName(),0).versionName

The SDK automatically adds event parameters in all events:

  • om_delta: the time difference (seconds) between when the event was created and when it was was sent

When the application code asks the SDK to send an event, the event is not immediately sent, instead the event is added to a in-memory queue. A lock is obtained for a extremely short time while adding. The persistent storage is located a SQLite database table 'events'. There's a background thread that periodically (every few seconds) polls the persistent storage for events. If there is an event, and network is reachable, the event is sent. The SDK uses the following code to determine the network reachability.

ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnected();

There is a sleep mechanism in the event sending. In the case of event sending fails, the sleep time between events is doubled. The max sleep is around one minute. When an event is successfully send, the sleep time is reset. The minimum sleep time is one second, i.e. max one event per second is sent.

https://<ORG_NAME>.analyzer.omniata.com/events?api_key=<API_KEY>&uid=<USER_ID>&<PARAMETERS>

Channel API

A Channel API request is made by calling channel-method, which is non-blocking. In case the Channel API responds successfully and the response is valid JSON, the onSuccess-method of the OmniataChannelResponseHandler given as a parameter is called. Correspondingly, in case of HTTP-level issues or invalid JSON onError-method is called. In both cases activity.runOnUiThread is used to wrap the call.

Traffic of a Channel API calling goes to:

https://<ORG_NAME>.engager.omniata.com/channel?api_key=<API_KEY>&uid=<USER_ID>&channel_id=<CHANNEL_ID>

Installation and upgrade

The Omniata Android SDK requires the following permissions in your ApplicationManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE”/>


Integrating Omniata Android SDK

Next place omniata-android-sdk.jar in your project's lib directory. Finally add an import for the SDK.

Upgrading to the latest version involves replacing the old jar with the new one. Then import the SDK package.

import com.omniata.android.sdk.*;

Initialize the library by calling the initialize function with the identifier of the user and the API key provided in the panel.

For initial testing it is recommended to track events in debug mode against the event monitor. This will allow you to debug your events in real-time.

<ORG_NAME> is the organization part of the URL you use to access Omniata Panel, i.e. https://organization.panel.omniata.com -> <ORG_NAME> would be organization

public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
...
//========================
// Initialize Omniata SDK
//========================
Activity activity = this;
String apiKey = "<API_KEY>";
String userId = "<USER_ID>";
String org = "<ORG_NAME>";

// Sends events to Production API
Omniata.initialize(activity, apiKey, userId, org);

...
}
...
}

This should be called whenever the user begins their session. If the events need to be sent to customized define Endpoint, here is the example of using, the channel API endpoint will also be changed in this case:

public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
...
//========================
// Initialize Omniata SDK with Customized BaseURL
//========================
Activity activity = this;
String apiKey = "<API_KEY>";
String userId = "<USER_ID>";
String org = "<ORG_NAME>";
String baseURL = "<BASE_URL>";

// Sends events to customized Event API, the event API should be baseURL+"/event?" and the channel API should be baseURL+"/channel?"
Omniata.initialize(activity, apiKey, userId, org, baseURL);

...
}
...
}

Tracking Load Event

Omniata.trackLoad();

Tracking Revenue Event

double total = 1.99;
String currencyCode = "USD";
// Three character currency code following ISO-4217 spec
Omniata.trackRevenue(total, currencyCode);

Tracking Custom Event

import org.json.JSONObject;
import org.json.JSONException;
...
JSONObject parameters = new JSONObject();
try{
parameters.put("xp", 1000);
parameters.put("level", 2);
} catch(JSONException e){
// do something
}

Omniata.track("level_up", parameters);

Tracking Advertiser ID

import org.json.JSONObject;
import org.json.JSONException;
...
JSONObject parameters = new JSONObject();
try {
     parameters.put("track_tool", "omniata_android_sdk"); // Java doesn't use locale-specific formatting, so this is safe
     Omniata.trackAdvertiserID(parameters);
} catch (JSONException e) {
     e.printStackTrace();
}

Loading Channel Message

//Channel message can be retrieved from mChannel.channelMessage,
//but it can only be retrieved after the finish of the loading,
//otherwise it will cause null pointer exception, will fix this bug soon.
int channel_id = 40;
OmniataChannelEngine mChannel = new OmniataChannelEngine();
//Load the channel message for certain channel
Omniata.channel(channel_id, mChannel);

Enable/Disable Push Notification in Omniata

//Send push token directly
String token = "<GCM Registration ID>"
Omniata.enablePushNotifications(token);

//Disable push notification
Omniata.disablePushNotifications();

In order to be get the GCM Registration ID, a Google project and a Server Key are needed which can be set in Google console. Check more details and example projects how to integrate with Android GCM here:

https://developers.google.com/cloud-messaging/android/start
https://developers.google.com/cloud-messaging/android/legacy-regid

Track Push Notification

When building the notification, the first step is to pass the content of the android gcm in the intent (here we store it in OmniataGCM):

Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("OmniataGCM", data);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
        PendingIntent.FLAG_ONE_SHOT);

Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_stat_ic_notification)
        .setContentTitle("test Message")
        .setContentText(message)
        .setAutoCancel(true)
        .setSound(defaultSoundUri)
        .setContentIntent(pendingIntent);

Then, in your activity class (here it's MainActivity), you can retrieve the bundle:

Bundle omData = intent.getBundleExtra("OmniataGCM");
if (omData != null) {
    Omniata.trackPushNotification(omData);
}

iOS SDK (including Apple Watch)

Features and technical description

Omniata's iOS SDK is implemented using Objective-C. By default the SDK does not log anything, i.e. uses SMT_LOG_NONE log level. The method setLogLevel of iOmniataAPI can be used to adjust the log level. When developing and testing a more verbose log level might be useful. Please note that the SDK uses NSMutableURLRequest class for the Channel API & Event API communication. The class is rather limited as it doesn't allow setting connection timeouts or request timeouts.

Event API

The iOS SDK automatically adds event parameters in om_load events:

  • om_device: the device model, obtained by code block:
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
  • om_platform: the platform: ios
  • om_os_version: the version of the operating system, [[UIDevice currentDevice] systemVersion]
  • om_sdk_version: the version of the SDK
  • om_discarded: the cumulative count of events the SDK has discarded, because the delivery has failed.

Additionally information of the application itself is added, see https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102364-TPXREF106:

  • om_ios_bundle_short_version_string: CFBundleShortVersionString, in XCode " Bundle versions string, short"
  • om_ios_bundle_version : CFBundleVersion, in XCode "Bundle version"
  • om_ios_bundle_identifier: CFBundleIdentifier, in XCode "Bundle identifier"

The SDK automatically adds event parameters in all events:

  • om_delta: the time difference (seconds) between when the event was created and when it was was sent

When the application code asks the SDK to send an event, the event is not immediately sent, instead the event is added to a in-memory queue. A lock is obtained for a very short time while adding. The persistent storage is located in file tmp/smt.events.log in NSHomeDirectory(). That directory is persisted even if the application is updated. There is a background thread that periodically (every few seconds) polls the persistent storage for events. If there is an event, and network is reachable, the event is sent.

By default the SDK uses the Reachability library from Apple to determine the network reachability. It's possible to plug-in a custom reachability check, consult the API docs for details. There's a retry mechanism in the event sending. In the case of event sending fails, the sending system sleeps a certain time and retries. In retried events there is an event parameter om_retry having the value of the how many retries have been made so far. If the event sending is retried multiple time, the sleep time between retries is doubled for each retry. When an event is successfully send, the sleep time is reset. The minimum sleep time is one second, i.e. max one event per second is sent. The max sleep is around one minute.

The traffic of an event goes to:

https://<ORG_NAME>.analyzer.omniata.com/events?api_key=<API_KEY>&uid=<USER_ID>&<PARAMETERS>

Channel API

A Channel API request is made by calling loadMessagesForChannel-method. After it finished, it will save the message in channelEngine.messages, which can be get by using getChannelMessages-method.

Traffic of a Channel API calling goes to:

https://<ORG_NAME>.engager.omniata.com/channel?api_key=<API_KEY>&uid=<USER_ID>&channel_id=<CHANNEL_ID>

Installation and upgrade

Add the following frameworks to your project by clicking on your Target, choosing the “Build Phases” tab and using the + button at the bottom of the “Linked Libraries” section.

  1. Foundation
  2. UIKit
  3. SystemConfiguration
  4. AdSupport

Copy the iOmniataAPI.framework to any directory in your app folder.

Drag it to your Xcode project.

Integrating Omniata iOS SDK

Getting Started

Include this header when using iOmnitaAPI

#import <iOmniataAPI/iOmniataAPI.h>

Initialize

NSString * api_key = @"<API_KEY>";
NSString * user_id = @"<USER_ID>";
NSString * org = @"<ORG_NAME>";
[iOmniataAPI initializeWithApiKey:api_key api_key: UserId:user_id OrgName:org]; // Tracks against production API

Initialization methods can be safely called multiple times or from multiple threads simultaneously, however only the first call initializes. The subsequent calls are ignored.

<ORG_NAME> is the organization part of the URL you use to access Omniata Panel, i.e. https://organization.panel.omniata.com -> <ORG_NAME> would be organization.

Initialize with custmized base URL

NSString * api_key = @"<API_KEY>";
NSString * user_id = @"<USER_ID>";
NSString * org = @"<ORG_NAME>";
NSString * url = @"<BASE_URL>";
// Sends events to customized Event API, the event API should be baseURL+"/event?" and the channel API should be baseURL+"/channel?"
[iOmniataAPI initializeWithApiKeyAndUrl:api_key api_key: UserId:user_id OrgName:org BaseUrl:url]; // Tracks against production API

Set API Key And UID

iOS SDK now only supports one time initialization. But the api key and uid can be reset by using the following method. And the after tracking events will use the updated api_key and user_id instead.

[iOmniataAPI setApiKey:api_key];
[iOmniataAPI setUserId:user_id];
Tracking Load Event
[iOmniataAPI trackLoadEvent];

Tracking Revenue Event

[iOmniataAPI trackPurchaseEvent:99.9 currency_code: @"EUR"];

Tracking Custom Event

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
              @"21", @"cash_balance",
              @"7", @"level",
              nil];

[iOmniataAPI trackEvent: @”quest_complete”: dictionary];

Tracking Advertiser ID

[iOmniataAPI trackAdvertiserID];

Loading Channel Message

A Channel API request is made by calling loadMessages. Internally the SDK calls the Channel API using HTTP. The call is asynchronously make using [NSURLConnection sendAsynchronousRequest]. The completionBlock that is given as a parameter to loadMessages is called after the Channel API call finished. In the successful case the messages can be retrieved using getChannelMessages.

Currently, a maximum of one Channel API call can be in progress at time.

[iOmniataAPI loadMessagesForChannel:40 completionHandler:^(OMT_CHANNEL_STATUS cs){
NSArray* message = [iOmniataAPI getChannelMessages];
}];

Enable/Disable Push Notification to Omniata.

Note: this section covers the client side implementation. You can find documentation for configuring your application for recieving push notifications at this page

In order to enable push notification, you need to request a device token that will enable the apple servers to identify the device.

The following snippet will allow you to request a device token (requires iOS version 8) :

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];

The delegate method didRegisterForRemoteNotificationsWithDeviceToken will provide you with the device token that you can pass to the omniata server by calling enablePushNotifications

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [iOmniataAPI enablePushNotifications:deviceToken];
}

You may need to track the received push notifications so you can use it in your reports. You can do so by calling our method trackPushNotification in the delegate method that apple provides : didReceiveRemoteNotification

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {
    [iOmniataAPI trackPushNotification:userInfo];
}

If you need to prevent a user from receiving push notification, you can use disablePushNotifications

[iOmniataAPI disablePushNotifications]

Debugging

There is a set of debug level values that you can use to set the log level.

[iOmniataAPI setLogLevel:SMT_LOG_VERBOSE];

Usage with Swift

To use the iOS SDK with Swift, a bridge header file is needed to import the Omniata iOS SDK header. Example contents of the bridge file is like this:

#ifndef _Bridging_Header_h
#define _Bridging_Header_h
#import "iOmniataAPI/iOmniataAPI.h"
#endif /* _Bridging_Header_h */

Search 'SWIFT_OBJC_BRIDGING_HEADER' in 'Build Settings' of the target, needs to add the bridge file path to the 'Object-C Bridging Header'.

Both 'iOmniataAPI.framework' and 'SystemConfiguration.framework' need to be added to the Link Binary Libraries. Example can be find in example apple watch project here. And then the iOS SDK methods can be calling in Swift,e.g.

let api_key = "<api_key>"
let user_id = "<uid>"
let org = "<org>"
iOmniataAPI.setLogLevel(SMT_LOG_VERBOSE)
iOmniataAPI.initializeWithApiKey(api_key, userId: user_id, orgName: org)
iOmniataAPI.trackLoadEvent()

Usage in Apple Watch

For Apple Watch usage, first it needs to expose iOS SDK header in the bridge file as described above. Then, add both 'iOmniataAPI.framework' and 'SystemConfiguration.framework' to the Link Binary Libraries to the WatchKit Extension target. Check the Example watch project for more details in the above link.

Unity3D Plugin

Features and technical description

Omniata Unity Plugin includes a C# file (Omniata.cs) to utilize the Omniata iOS SDK and Omniata Android SDK. If you want to use any feature of Omniata iOS SDK or Omniata Android SDK that the Unity Plugin doesn't support, you can have a look at the Omniata.cs class to see how to make the iOS SDK or Android SDK methods visible in Unity.

As the native SDKs handle sending of events and Channel API requests, the functionality of the SDKs is identical to their functionality as if they were used as such, i.e. without Unity3D. This means for example that the om_sdk_version is the native SDK version. The Unity Plugin adds a parameter om_unity_sdk_version with the correct value (in om_load) to identify that the event is from Unity Plugin and to identify the version of the Unity Plugin.

The Unity Plugin supports the usage of iOS and Android environment. The Webplayer is partly supported without establishing the events queue.

Events tracking in the Editor is not supported at the moment since this plugin is made for calling native iOS and Android SDK methods.

iOS

The plugin uses open source XUPorter (inside of the 'Editor' folder of the Unity project) to add the iOS framework automatically into the Xcode project during the building process, since XUPorter does not support adding external framework into 'Frameworks' repository for now, the plugin creates a new repository 'Omniata' and adds our iOS SDK inside.

The Plugin externs the iOS NSLog method from iOS with 'P' as a TAG for debugging, you can check the log message after build Unity project to Xcode project.

Android

The plugin externs the native Java methods from the Android SDK. The SDK asks for two permissions in AndroidManifest.xml file:
"android.permission.INTERNET" and "android.permission.ACCESS_NETWORK_STATE". Besides, the following meta element needs to be included inside of application node:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

The plugin includes google-play-services_lib folder since it is needed to get the Google advertiser ID, the folder can be found in the following path:

<Android SDK PATH>/extras/google/google_play_services/libproject/google-play-services_lib

When building to Android project, the "package" name inside of AndroidManifest.xml should be the same with the 'Bundle Identifier' name in the 'Player Settings' of unity project. Check example project for more details.

The plugin externs the Android Log.i method with 'Omniata' as a TAG for debugging, you can check the log message inside of a Eclipse LogCat.

Log Level

The log level can be set for both iOS and Android. The level value is Verbose, Debug, Info, Warn, Error and Assert. The level can be set either in the Omniata.prefab or by SetOmLoglevel-method.

Other Platform

The plugin also includes a basic version of all the features for testing of other platforms. There is no events queue inside of the implementation. The HTTP GET request is sent by using StartCoroutine-method.

Event API

Details of how the plugin works under iOS and Android, check the details Omniata iOS SDK document and Android SDK document.

Installation and Upgrade

The installation of Omniata Unity3D Plugin in your Unity3D application consists of these steps:

  1. Obtain the latest Omniata Unity3D Plugin, see instruction above. It’s a Unity package file with name like OmniataSDK-1.1.0.unitypackage.
  2. Click Assets -> Import Package -> Custom Package. There is an example project in the package, it's optional to import that.

To update to the latest version:

  1. Obtain the latest Omniata Unity SDK. It’s a Unity package file with name like OmniataSDK-1.0.0.unitypackage.
  2. Remove the directory Omniata from your Unity project, 'OmniataiOSPlugin.m' file inside of Plugins/iOS and Omniata inside of Editor. Remove also 'AndroidManifest.xml' and 'Omniata-android-sdk.jar' inside of Plugins/Android
  3. Click Assets -> Import Package -> Custom Package. There is a Example project in the package, it's optional to import that.

Integrating Omniata Unity SDK

Once the Omniata Unity Plugin code has been installed in your application, you can start integrating it.
The code file Omniata.cs is (by default) under located in Assets/Omniata with the namespace 'OmniataSDK'. The parameters need to be given is api_key, uid and org.

  • api_key - This identifies your application and environment (among others). Note you will probably have multiple API Keys - one for Omniata Environment. The semantics of API Key is described elsewhere.
  • uid - This uniquely identifies the end user.
  • org - Your organization name. This essentially is the organization in the URL you use to access Omniata Panel (http://organization.panel.omniata.com). The SDK uses org to send traffic to Omniata Event URLs and Channel URLs like https://<organization>.analyzer.omniata.com/event?parameters and https://<organization>.engager.omniata.com/channel?parameters.

There are two ways to initialize the Omniata instance:

  1. Add Omniata.prefab as a Component to your scene and set the API_KEY, UID, ORG and corresponding loglevel. The Awake-method inside of Omniata.cs will be called to initialize Omniata once. After that you can call get the instance of Omniata and start using the API method.
  2. Another way is 'Start Manually', check the 'Start Manually' inside of Omniata.prefab, after import of the Omniata library, the parameters can be passed manually as followed.

Note: Since this plugin is based on Omniata iOS and Android SDK, in iOS SDK, appDidLaunch-method can be called multiple times, but only the first call will be effective. While in Android SDK appDidLaunch-method can be called multiple times and the last call will override the previous call.

// Import omniata library
using OmniataSDK;
// Get the instance of Omniata
Omniata.Instance.appDidLaunch("a514370d", "uidtest", "testorg", Omniata.LogLevel.Debug);

Now the Omniata SDK is ready to be used.

Note: The plugin will send events only when there is network connectivity. If there is no network connectivity, the events will be added to the queue and be send one by one once the network is back. Check the iOS and Android SDK sections for details. For other platforms, Omniata.cs will start a new coroutine with StartCoroutine-method and use the send events method.

Initialize with the customized Tracking URL endpoint example:

// Import omniata library
using OmniataSDK;
// Get the instance of Omniata. 
// Send events to customized Event API.
// The event API should be baseURL+"/event?"
// The channel API should be baseURL+"/channel?"
Omniata.Instance.appDidLaunch("a514370d", "uidtest", "testorg", Omniata.LogLevel.Debug, "customizedurl.omniata.com");

Tracking Load Event

// Track load
Omniata.Instance.TrackOmLoad();
// Track load with additional parameters
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("para", "testpara");
Omniata.Instance.TrackOmLoad(parameters);

Tracking Revenue Event

// Track Revenue
double total = 99.9;
string currency_code = "EUR";
omniata.TrackOmRevenue(total,currency_code);

// Track Revenue with additional parameters
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("para", "testpara");
Omniata.Instance.TrackOmRevenue(total, currency_code, parameters);

Tracking Custom Event

// Tracking a Customized Event
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("app", "testapp");
parameters.Add("attack.attacker_won", "0");
string type="testing_type";
Omniata.Instance.TrackOm(type,parameters);//track customised events

Tracking Advertiser ID

// Tracking Advetiser ID
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("track_tool", "omniata_unity_sdk");
Omniata.Instance.TrackOmAdvertiserID(parameters);

Loading Channel Message

Channel message loading supports only iOS for now, and the message can be seen in the console of the Xcode. For other platforms other than iOS and Android, a similar method of Channel API calling can also be used. Usage example is:

// Load channel message
int ChannelId = 40;
Omniata.Instance.LoadOmChannelMessage(ChannelId); //load message

Enable Push Notification in Omniata

To enable push notification, Omniata Unity Plugin supports sending the token to Omniata.

byte[] token = NotificationServices.deviceToken;
Omniata.Instance.EnablePushNotificationsFromTokenBytes(token);
  • Android: there are Unity GCM extentions (GCM folder under Plugins, and gcm.jar and unitygcmplugin.jar under Plugin/Android), e.g.
GCM.SetRegisteredCallback ((string registrationId) => {
    Omniata.Instance.EnableOmPushNotifications(registrationId);
});

Detail of GCM extentions can be found here: unity-gcm and unity-gcm-guide. To test with GCM, there is also a tool available here.

JavaScript SDK

Setup

We load the library onto the page asynchronously, this keeps your page loading smoothly.

Place the following code snippet inside the <HEAD> tag of your website you wish to add tracking to.

<script>
(function(document,a){window.omniata=a;var js,fjs;js=document.createElement("script");
js.type="text/javascript";js.async=!0;js.src="https://s3.amazonaws.com/js-sdk.omniata.com/omniata-1.0.0.js";
fjs=document.getElementsByTagName("script")[0];fjs.parentNode.insertBefore(js,fjs);a._q=[];
a.init=function(options){function def(obj,fn_name){var fn_name_parts=fn_name.split(".");
2==fn_name_parts.length&&(obj=obj[fn_name_parts[0]],fn_name=fn_name_parts[1]);
obj[fn_name]=function(){obj._q.push([fn_name].concat(Array.prototype.slice.call(arguments,0)))}}fn_names=["init","track","trackPage"];
for(i=0;i<fn_names.length;i++)def(a,fn_names[i]);a.init(options)};a.SNIPPET_VERSION=1})(document,window.omniata||[]); </script>

Tracking Load Event

Initialize the library by calling the init function with the identifier of the user and the api key provided on your project's summary page.

<script> omniata.init({api_key:"YOUR_API_KEY",uid:"7"}); omniata.track('om_load'); </script>

Tracking Custom Event

<script> // uid and api key from init will be sent automatically. omniata.track('viewed_house', { cost: 1186504, type: 'condo', bed: 2, bath: 2, sqft: 1337, location: 'Hollywood', zip: 90028 }); </script>

Callbacks

Callbacks are useful if you want to trigger an action after an event has been tracked. For example, perhaps you want to track an event so a user will be placed in a segment and then run an ad targeted to that segment.

<script> // uid and api key from init will be sent automatically. omniata.track('viewed_house', { cost: 1186504, type: 'condo', bed: 2, bath: 2, sqft: 1337, location: 'Hollywood', zip: 90028 }, function(){ alert('event sent'); }); omniata.track('foo', function(){ alert('foo event sent'); }); omniata.track({ om_event_type: 'foo', bar: 'baz' }, function(){ alert('foo event sent'); }); </script>

PHP SDK

Features and technical description

Omniata PHP SDK uses curl_exec-method to send events to Omniata Event API, and return the response by calling Omniata Channel API.

Installation and upgrade

To install the Omniata PHP SDK:

  1. Obtain the latest Omniata PHP SDK. It’s a compressed file with name like omniata-php-sdk.zip.
  2. Unzip the package to the project folder.

To update to the latest version:

  1. Obtain the latest Omniata PHP SDK. It’s a compressed file with name like omniata-php-sdk.zip.
  2. Remove the directory Omniata from your project repository.
  3. Replace with the Omniata folder inside of the new package.

Note: There is a example project in the package which is entirely optional to include.

Integrating the Omniata PHP SDK

Once the Omniata PHP SDK has been included in your PHP application, you can start using it.

First, you need to include the library in the PHP application.

// Include the two files in the PHP app
require_once(dirname(__FILE__) . "/../Omniata/Client.php");
require_once(dirname(__FILE__) . "/../Omniata/OmniataUrl.php");

Then in the file, initiate the library with declaration of a new 'Client' instance.

$api_key = "<API_KEY>";
$uid = "<UID>";
$org = "<ORG_NAME>";
$client = new Client($api_key, $uid, $org);

Tracking Event

To track events, define the parameters in an array.

$eventPara = array(
"om_event_type" => "",
"level" => "level 4",
);
$client->track($eventPara);

Loading Channel Message

To get channel message, call method with channel ID.

$channel_id = "40";
$content=$client->deliver($channel_id);

This article was last updated on December 2, 2016 08:16. If you didn't find your answer here, search for another article or contact our support to get in touch.

Contact Sales

Add Phone Number