Apxor Web SDK
Install through NPM
npm install --save apxor
SDK Initialization
ImportApxor
sdk and initialize it in application root component or pageimport Apxor from "apxor"; // ES6
//var Apxor = require('apxor'); // ES5
Apxor.init("YOUR_SITE_ID", {
// Configuration options
});
Configuration Options
Note:
Contact support@apxor.com to get your unique SITEID
Initialize Plugins
- Run the following command in your terminal
npm install --save apxor-qe apxor-rtm
- Add the following import statements in your root component or page. Make sure you add lint ignore lines for both of these lines, if you use
lint
import CE from "apxor-qe";
import ApxorRTM from "apxor-rtm";
- Add the following value in
Configuration option's
plugin
anddeps
array
Apxor.init("YOUR_SITE_ID", {
// ...
plugins: ["ApxorRTM"],
deps: [ApxorRTM, CE],
// ...
});
APIs
UserId
A unique user identifier that you can assign to the userUsage:
Apxor.setUserId(String);
Example:
Apxor.setUserId("user@example.com");
PageView
You can log a page view event when users navigate through your websiteUsage:
Apxor.logPageView(String); //String URL pathname
Example:
Apxor.logPageView("/about.html");
App Events
Usage:Apxor.logEvent(eventName, eventProperties);
Example:
Apxor.logEvent("ADD_TO_CART", {
userId: "user@example.com",
value: 1299,
item: "Sony Head Phone 1201",
});
User Properties
Usage:Apxor.setUserProperties({
userProperty1: "value1",
userProperty2: "value2",
});
Example:
Apxor.setUserProperties({
gender: "Male",
age: 24,
isPaidUser: true,
creditsLeft: 250,
});
Session Properties
Usage:Apxor.setSessionProperties({
property1: "value1",
property2: "value2",
});
Example:
Apxor.setSessionProperties({
language: "en",
location: "Hyderabad",
});
Get Client Id
Use this API to get the unique identifier that Apxor SDK generates for this userExample:
const clientId = Apxor.getClientId();
Start New Session
Starts new session if there is no active session. If a session is already in progress, it acts as a no-opApxor.startNewSession();
End Session
Ends the active session if any active session in progress. After this call, none of the Apxor APIs work, except startNewSession() API.Apxor.endSession();
Handle Deeplink Redirection
For single page applications built with React/Angular/Vue, you need to handle the internal redirection on your own by using thesetRedirectionHandler
method.Example
Apxor.setRedirectionHandler((url) => {
// Interpret the URL and redirect user to the specific URL
});