API Documentation

Android

Initializing the Apxor SDK

To start tracking with the Apxor Android SDK, you must first initialize it with your project token. To initialize the SDK,

ApxorSDK.initialize(<APXOR_ID> , this.getApplicationContext());

Identifying Users

The Apxor SDK automatically captures device IDs which the Apxor backend uses to uniquely identify users.

If you want to, you can assign your own user IDs. This is particularly useful if you want to study a specific user with ease. To assign your own user ID, you can use

ApxorSDK.setUserIdentifier(<SOME_USER_ID>);

User Attributes

There is often additional user identifying information, such as name and email address, connected with the external IDs.

To add some more attributes that are specific to a particular user,

HashMap<String, String> userInfo = new HashMap<>();
userInfo.put("age", "27");
userInfo.put("gender", “Male");
ApxorSDK.setUserCustomInfo(userInfo);

Session Attributes

A Session can be simply defined as user journey as he opens the app, until he closes the app. There can be various pieces of information that be very impactful when accumulated in a session. For example, location in a session can be useful to know exactly where, the user is utilizing the app most.

To add session attributes that are specific to a session,

ApxorSDK.setSessionCustomInfo("network", "4G");

Or if you have multiple key value pairs that need to be logged, you can simply put them in a hashmap like,

HashMap<String, String> sessionInfo = new HashMap<String, String>();
sessionInfo.put("network", "4G");
sessionInfo.put("city", "GAJ");
ApxorSDK.setSessionCustomInfo(sessionInfo);

Reporting Custom Errors

Custom errors describe situations like LOGIN_FAILED, NETWORK_CALL_FAILED and are to be treated differently compared to app events. So these are treated as errors and are shown on the issues page to let you know their impact.

A custom error takes the exception itself and some context (what? OR which?) to make it easy for you identify. To report a custom error,

Exception e = new Exception(“LOGIN FAILED EXCEPTION”);
HashMap<String, String> additionalInfo = new HashMap<>();
additionalInfo.put("email", "spock@vulcan.com");
additionalInfo.put("cause", "network failure");
ApxorSDK.reportCustomError("Null Value", additionalInfo, e);

App Events

App events make it easier to analyze user behavior and optimize your product and marketing around common business goals such as improving user retention or app usage. You can also add additional information for any event.

To track an event with the event name and properties.

HashMap<String, String> additionalInfo = new Hash<>();
additionalInfo.put("event_type", "SelectLanguage");
additionalInfo.put("language", "Valyrian");
ApxorSDK.logAppEvent(“Logout”, additionalInfo);

iOS

Initializing the library

To start tracking with the Apxor iOS SDK, you must first initialize it with your Apxor ID. To initialize the SDK,

[ApxorSDK initialize:@"<YOUR_APXOR_ID>"];

Identifying Users

The Apxor SDK automatically captures device IDs which the Apxor backend uses to uniquely identify users.

If you want to, you can assign your own user IDs. This is particularly useful if you want to study a specific user with ease. To assign your own user ID, you can use

[ApxorSDK setUserIdentifier:@"1729"];

User Attributes

There is often additional user identifying information, such as name and email address, connected with the external IDs.

To add some more attributes that are specific to a particular user,

NSDictionary *info = [[NSDictionary alloc] init];
[info setValue:@"email" forKey:@"spock@vulcan.com"];
[info setValue:@"location" forKey:@"In a galaxy far far away"];
[ApxorSDK setUserCustomInfo:info];

Session Attributes

A Session can be simply defined as user journey as he opens the app, until he closes the app. There can be various pieces of information that be very impactful when accumulated in a session. For example, location in a session can be useful to know exactly where, the user is utilizing the app most.

To add session attributes that are specific to a session,

NSDictionary *info = [[NSDictionary alloc] init];
[info setValue:@"email" forKey:@"spock@vulcan.com"];
[info setValue:@"location" forKey:@"In a galaxy far far away"];
[ApxorSDK setSessionCustomInfo:info];

Reporting Custom Errors

Custom errors describe situations like LOGIN_FAILED, NETWORK_CALL_FAILED and are to be treated differently compared to app events. So these are treated as errors and are shown on the issues page to let you know their impact.

A custom error takes the exception itself and some context (what? OR which?) to make it easy for you identify. To report a custom error,

NSException* myException = [NSException
                            exceptionWithName:@"FileNotFoundException"
                            reason:@"File Not Found on System"
                            userInfo:nil];
[ApxorSDK reportCustomError:myException withContext:@"customException"];

App Events

App events make it easier to analyze user behavior and optimize your product and marketing around common business goals such as improving user retention or app usage. You can also add additional information for any event.

To track an event with the event name and properties.

NSDictionary *info = [[NSDictionary alloc] init];
[info setValue:@"event_type" forKey:@"SelectLanguage"];
[info setValue:@"language" forKey:@"Valyrian"];
[ApxorSDK logAppEventForEvent:@"LANG_SELECT" withInfo:info];

Apxor Web SDK

Manually add and initialize script in your page (for SSR)

<script>
(function(a,p,x,o,r){
  Apxor=a.Apxor||{_q:[]};
  ["init","setUserId","setUserProperties","setSessionProperties","logPageView","logEvent"].forEach(function(m){Apxor[m]=function(){this._q.push({m:m,args:arguments});}});
  r=p.createElement(x);r.type='text/javascript';r.async=true;r.src='https://unpkg.com/apxor';o=p.getElementsByTagName(x)[0];o.parentNode.insertBefore(r,o);

  Apxor.init('YOUR_SITE_ID');

})(window,document,'script');
</script>

Or Automatically install SDK through NPM (for SPA)

npm i -s apxor
Import and initialize SDK in root of your application

To start tracking with the Apxor Web SDK, you must first initialize it with your site ID. To initialize the SDK,

import Apxor from 'apxor'; //ES6
//var Apxor = require('apxor'); //ES5

Apxor.init('YOUR_SITE_ID', {
    debug: false ,//if true, enables logs [dev]
    honorDNT: false ,//if true, SDK disables in browsers with doNotTrack flag
    idle_time_out: 3600 //in seconds: idle or background time to timeout session
});

APIs

To get started with any of the following APIs first import the Apxor Library using

import Apxor from 'apxor';
Identifying Users

You can assign your own user IDs. This is particularly useful if you want to study a specific user with ease. To assign your own user ID, you can use

Apxor.setUserId(String);

Eg:

Apxor.setUserId("user@example.com");

Track Screen View

For SPA, use the following to log the page view for client side rendering applications, this notifies the SDK about the change in the page being currently viewed. This is strictly not for Server rendering applications.

Apxor.logPageView(location.pathname); //String URL pathname

Eg:

Apxor.logPageView("/about.html");

App Events

Events make it easier to analyze user behavior and optimize your product and marketing decisions around common business goals. You can also add additional information for that event that you feel is important to analyze later.

To track an event with the event name and properties.

Apxor.logEvent(name, properties, [category]); //All Strings

Eg:

Apxor.logEvent("ADD_TO_CART", {
    "userId": "user@example.com",
    "value": "1299",
    "item": "Sony Head Phone 1201"
}, "PRODUCT_PURCHASE");

User Attributes

There is often additional user identifying information, such as name and email address, connected with the external IDs.

To add some more attributes that are specific to a particular user,

Apxor.setUserProperties({
    "property1": "value",
    "property2": "value2"
});

Eg:

Apxor.setUserProperties({
    "gender": "male",
    "age": "24"
});

Session Attributes

A Session can be simply defined as user journey as he opens the site, until he closes it. There can be various pieces of information that be very impactful when accumulated in a session.

To add session attributes that are specific to a session,

Apxor.setSessionProperties({
    "property1": "value",
    "property2": "value2"
});

Eg:

Apxor.setSessionProperties({
    "language": "en",
    "location": "Hyderabad"
});

React Native

Getting started

$ npm install apxor-react-native-sdk --save

Mostly automatic installation

$ react-native link apxor-react-native-sdk

Manual installation

Android
  1. Open up android/app/src/main/java/[...]/MainActivity.java
  2. Add import com.apxor.reactnativesdk.ApxorReactNativeSdkPackage; to the imports at the top of the file
  3. Add new ApxorReactNativeSdkPackage() to the list returned by the getPackages() method
  4. Append the following lines to android/settings.gradle:
    include ':apxor-react-native-sdk'
    project(':apxor-react-native-sdk').projectDir = new File(rootProject.projectDir,     '../node_modules/apxor-react-native-sdk/android')
Additional steps todo
  1. Insert the following lines inside repositories block in android/build.gradle

    maven { url "http://repo.apxor.com/artifactory/list/libs-release-android/" }
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

    compile project(':apxor-react-native-sdk')
    implementation 'com.apxor.android:apxor-android-sdk-core:2.3.7@aar'
  3. Insert the following lines in the onCreate method in android/app/src/main/java/(package)/MainApplication.java:

    ApxorSDK.initialize("<APP_ID>", MainApplication.this);

Note:

  • The second argument, MainApplication.this, makes sures to provide ApplicationContext instead of ReactApplicationContext for ApxorSDK to work properly.
  • If you change the application class name (default: MainApplication), make sure to use your_class_name.this instead.

Usage

import ApxorReactNativeSdk from 'apxor-react-native-sdk';
UserId
ApxorReactNativeSdk.setUserIdentifier("user_id");

Example

ApxorReactNativeSdk.setUserIdentifier("<some_user_id>");
Events
ApxorReactNativeSdk.logAppEvent(event_name, properties);

Example

ApxorReactNativeSdk.logAppEvent("ADD_TO_CART", {
"userId": "user@example.com",
"value": "1299",
"item": "Sony Head Phone 1201"
});
User Properties
ApxorReactNativeSdk.setUserCustomInfo(properties);

Example

ApxorReactNativeSdk.setUserCustomInfo({
"property1": "value",
"property2": "value2"
});
Track Navigation
ApxorReactNativeSdk.logNavigationEvent(screen_name);

Example

ApxorReactNativeSdk.logNavigationEvent("LoginScreen");