Dengage Android SDK for sending visitor behavior and rendering product recommendations.
Supports Android 4.4 and higher devices.
Important warning
ProductView, Basket Add/Remove, View Basket, Purchase and Click events must match productId.
This tutorial provides a very simple and quick introduction to the Dengage integration for Android applications by walking you through details of different events.
To see sample application using Android SDK, please check Android SDK repository.
This guide will help you to integrate different events (visitor actions) and also product recommendations.
Dengage uses different event types for different visitor actions. You can define following events by using Dengage Android SDK:
If your request body has a field statusCode
, then you have an error in your request. Details of errors are given in below table:
Every event in Dengage shares common parameters and you can add these parameters to all events that will be defined later.
Details of common parameters for events are given below:
Dengage accounts have two important system variables used in integration: APP KEY and Data Center. You can access these values from Integrations menu of Dengage Panel:
To access Integrations menu of Dengage Panel, please login to your Dengage account and navigate to
Settings > Integrations
.
You can do it with an extended class from the application class as follows. (We recommend it)
package xxx;
import android.app.Application;
import com.segmentify.segmentifyandroidsdk.SegmentifyManager;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
//SegmentifyManager.INSTANCE.config(this,apiKey,dataCenter,domain);
SegmentifyManager.INSTANCE.config(this,"xxx-xxx-xxxx-xxxx-xxxxx","https://xxxx.segmentify.com","xxxx.com");
}
}
You should add this class in AndroidManifest.xml
android:name=".MyApplication"
You can use the following command to set new configs
SegmentifyManager.INSTANCE.setConfig("newApiKey","newDataCenterUrl","newDomain");
Basic response method for spesific event;
SegmentifyManager.INSTANCE.sendPageView(
"Home Page",
null,
new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
// parse recommendation results and render to the webpage
}
}
);
Callback returns as a one-dimensional array. Optional operation on the array can be done to show it in the UI. Widget View is used when the page's widget is actually displayed. Related title: Interaction
SegmentifyManager.INSTANCE.sendPageView(
"Home Page",
null,
new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
// parse recommendation results and render to the webpage
// check if recommendations are active for this page
// and there is recommendations to be rendered
if(data != null) {
// loop through each recommendation
for (int i = 0; i < data.size(); i++) {
RecommendationModel recommendationMdl = data.get(i);
// check for a specific campaign
if(recommendationMdl.getInstanceId() == "scn_XXXXXXXXXXX") {
// render recommendations
ArrayList<ProductRecommendationModel> products =
recommendationMdl.getProducts();
}
}
}
}
}
);
When a visitor views a view controller, this event should be sent.
Parameters can be sent with page view event is given below (you can also add common parameters):
An example Page View request is given below:
//define page model object
PageModel model = new PageModel();
model.setCategory("Home Page");
//send page view request
SegmentifyManager.INSTANCE.sendPageView(model, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
An example of parameterized use as an alternative;
//send page view request
SegmentifyManager.INSTANCE.sendPageView("Home Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
When a visitor wants to search products, this event should be sent.
There are two search type before search input and after search input. Before search input module works until the search is done. After search input starts working after searching. These recommendations are updated after minimum characters written in the search bar. Minimum character count presents in the campaign that is in search request response.
Parameters can be sent with search event is given below (you can also add common parameters):
An example search view request is given below:
//define search page model object
SearchPageModel searchPage = new SearchPageModel();
searchPage.setQuery("Dress");
//send search page view request
SegmentifyManager.INSTANCE.sendSearchPageView(searchPage, new SegmentifyCallback<SearchResponseModel>() {
@Override
public void onDataLoaded(SearchResponseModel data) {
}
});
SearchModel has two objects: products for product list, and campaign for search campaign details.
When a visitor views a product, this event should be sent.
If product is also inside a page, don't forget to send a page view event with category 'Product Page' and subCategory product's category too.
Parameters can be sent with product view event is given below (you can also add common parameters):
An example product view request is given below:
//define page model object
PageModel model = new PageModel();
model.setCategory("Product Page");
model.setLang("EN");
model.setRegion("EU");
//send page view request
SegmentifyManager.INSTANCE.sendPageView(model, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//define product model object
ProductModel model = new ProductModel();
ArrayList<String> categories = new ArrayList<String>();
categories.add("Womenswear");
model.setProductId("25799860937");
model.setCategories(categories);
model.setPrice(578.00);
model.setTitle("Asymmetric Dress in Black");
model.setImage("//cdn.shopify.com/s/files/1/1524/5822/products/2014_11_17_Lana_Look034_02_300x300.jpg?v=1475497696");
model.setUrl("https://Segmentify-shop.myshopify.com/products/asymmetric-dress-black");
//send product view request
SegmentifyManager.INSTANCE.sendProductView(model, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
An example of parameterized use as an alternative;
//send page view request
SegmentifyManager.INSTANCE.sendPageView("Product Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
ProductModel model = new ProductModel();
ArrayList<String> categories = new ArrayList<String>();
categories.add("Womenswear");
SegmentifyManager.INSTANCE.sendProductView("25799860937","Womenswear",578.00,"Asymmetric Dress in Black","//cdn.shopify.com/s/files/1/1524/5822/products/2014_11_17_Lana_Look034_02_300x300.jpg?v=1475497696",
"https://segmentify-shop.myshopify.com/products/asymmetric-dress-black")
, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
Dengage uses basket operations as intermediary step for measuring success of recommendations throughout the conversion funnel. Basket success rate is also reported by Trendify and Bannerify to show individual performance of products, categories, brands and banners.
Basket operations are similar to page view and product view. There are two possible steps in a basket operation these are: add product to basket, remove product from basket.
When a visitor adds a product to basket/cart, this event should be sent.
An example request is given below:
//Define basket operations model
BasketModel model = new BasketModel();
model.setStep("add");
model.setProductId("25800400265");
model.setQuantity(2);
model.setPrice(358.00);
//Send add to basket event
SegmentifyManager.INSTANCE.sendAddOrRemoveBasket(model);
An example of parameterized use as an alternative;
//Send add to basket event
SegmentifyManager.INSTANCE.sendAddOrRemoveBasket("add","25800400265",2,358.00);
When a visitor removes a product from basket/cart, this event should be sent.
An example request is given below:
//Define basket operations model
BasketModel model = new BasketModel();
model.setStep("remove");
model.setProductId("25800400265");
model.setQuantity(2);
model.setPrice(358.00);
//Send add to basket event
SegmentifyManager.INSTANCE.sendAddOrRemoveBasket(model);
An example of parameterized use as an alternative;
SegmentifyManager.INSTANCE.sendAddOrRemoveBasket("remove","25800400265",2,358.00);
Parameters can be sent with basket operations event is given below (you can also add common parameters):
Dengage uses checkout operations to measure success of recommendations throughout the conversion funnel. Checkout information and steps are also used in email & personalization campaigns. Campaign, Trendify, Bannerify and Sales reports are feed from checkout information. It is essential for both analyitcs and recommendation capabilities to function properly.
Dengage track four different steps of checkout operation:
View Basket is the first step of checkout funnel, and followed by Customer Information.
When a visitor views his/her basket/cart, this event should be sent with basket details.
An example request is given below:
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Basket Page", null, new SgmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
CheckoutModel checkoutModel = new CheckoutModel();
checkoutModel.setProductList(productList);
checkoutModel.setTotalPrice(156.0);
SegmentifyManager.INSTANCE.sendViewBasket(checkoutModel, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
An example of parameterized use as an alternative;
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Basket Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
SegmentifyManager.INSTANCE.sendViewBasket(156.00,productList,null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
Customer Information is the second step of checkout funnel, and preceeded by View Basket & followed by Payment Information.
When a visitor enters customer information as second step of checkout funnel, this event should be sent with basket details.
An example request is given below:
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Customer Info Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
CheckoutModel checkoutModel = new CheckoutModel();
checkoutModel.setProductList(productList);
checkoutModel.setTotalPrice(156.0);
SegmentifyManager.INSTANCE.sendCustomerInformation(checkoutModel, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
An example of parameterized use as an alternative;
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Customer Info Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
SegmentifyManager.INSTANCE.sendCustomerInformation(156.00,productList,null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Payment Information is the third step of checkout funnel, and preceeded by Payment Information & followed by Purchase/Success.
When a visitor enters payment information as third step of checkout funnel, this event should be sent with basket details.
An example request is given below:
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Checkout Payment Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
CheckoutModel checkoutModel = new CheckoutModel();
checkoutModel.setProductList(productList);
checkoutModel.setTotalPrice(156.0);
SegmentifyManager.INSTANCE.sendPaymentInformation(checkoutModel, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
An example of parameterized use as an alternative;
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Checkout Payment Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
SegmentifyManager.INSTANCE.sendPaymentInformation(156.00,productList,null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Purchase/Success is the fourth and final step of checkout funnel, and preceeded by Payment Information.
When a visitor finalizes a purchase, this event should be sent with basket details.
An example request is given below:
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Checkout Success Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
CheckoutModel checkoutModel = new CheckoutModel();
checkoutModel.setProductList(productList);
checkoutModel.setTotalPrice(156.0);
checkoutModel.orderNo("order1");
SegmentifyManager.INSTANCE.sendPurchase(checkoutModel, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
An example of parameterized use as an alternative;
//START Page view request
SegmentifyManager.INSTANCE.sendPageView("Checkout Success Page", null, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Page view request
//START Basket View Request
ArrayList<ProductModel> productList = new ArrayList<>();
ProductModel productModel = new ProductModel();
productModel.setPrice(78.0);
productModel.setQuantity(2);
productModel.setProductId("25799809929");
productList.add(productModel);
SegmentifyManager.INSTANCE.sendPurchase(156.00,productList,"OrderNo1", new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
//END Basket View Request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Detailed explanation for each parameter is given below:
Each product inside the basket can be defined with following parameters. See Checkout Parameters for defining checkout operation in which basket product is also defined.
Dengage tracks important user operations like sign-up/register, sign-in/login, sign-out/logout and also you can share your customer's information with Dengage by sending an update event.
Important warning
The userid must be used for the unification operation on all channels in the same userId. See the success department for the web side
There are 4 possible user/visitor operations:
When a visitor registers (sign-up) to your website, you should send a new user event.
If you want to share details of an already registered user with Dengage, please use User Update.
Details of parameters of new user is given below:
An example request is given below:
//Create new user Object
UserModel userModel = new UserModel();
//Define user object's username and email
userModel.setUsername("Segmentify");
userModel.setEmail("example@Segmentify.com");
//Send user register request
SegmentifyManager.INSTANCE.sendUserRegister(userModel);
An example of parameterized use as an alternative;
//Send user register request
SegmentifyManager.INSTANCE.sendUserRegister("Segmentify","example@Segmentify.com");
When a registered customer logins (sign-in), a user login event should be sent to Dengage.
Details of parameters of user login is given below:
An example request is given below:
//Create new user Object
UserModel userModel = new UserModel();
//Define user object's username and email
userModel.setUsername("Segmentify");
userModel.setEmail("example@Segmentify.com");
//Send user register request
SegmentifyManager.INSTANCE.sendUserLogin(userModel);
An example of parameterized use as an alternative;
//Send user login request
SegmentifyManager.sharedManager().sendUserLogin("Segmentify","example@segmentify.com")
When a registered customer logouts (sign-out), a user logout event should be sent to Dengage.
Details of parameters of user logout is given below:
An example request is given below:
//Create new user Object
UserModel userModel = new UserModel();
//Define user object's username and email
userModel.setUsername("Segmentify");
userModel.setEmail("example@segmentify.com");
//Send user register request
SegmentifyManager.INSTANCE.sendUserLogout(userModel);
An example of parameterized use as an alternative;
//Send user login request
SegmentifyManager.sharedManager().sendUserLogout("Segmentify","example@segmentify.com")
When you want to share an already registered customer information, provide details of the customer by sending an user update event. You can use both this integration for both frequently updating user information and instant updates when customer updates his/her personal information.
If you want to share a new registered user with Dengage, please use New User.
Details of parameters of user update is given below:
An example request is given below:
//Create new user Object
UserModel userModel = new UserModel();
//Define user object's username and email
userModel.setUsername("Segmentify");
userModel.setEmail("example@segmentify.com");
//Send user register request
SegmentifyManager.INSTANCE.sendUserUpdate(userModel);
An example of parameterized use as an alternative;
//Send user update request
SegmentifyManager.sharedManager().sendUserUpdate("Segmentify","example@segmentify.com")
This event is used when userid wants to be changed.
UserChangeModel model = new UserChangeModel();
model.setUserId("XXXXXXXXXX");
SegmentifyManager.INSTANCE.sendChangeUser(model;
This integration enables any event & data important for you to be tracked by Dengage and become actionable. With this integration, you can send any non standard events & data to Dengage, and gives endless opportunities to track and take actions to your visitor's behaviour.
Details of parameters of custom event is given below:
An example request is given below:
CustomEventModel model = new CustomEventModel();
model.setType("test");
SegmentifyManager.INSTANCE.sendCustomEvent(model, new SegmentifyCallback<ArrayList<RecommendationModel>>() {
@Override
public void onDataLoaded(ArrayList<RecommendationModel> data) {
}
});
Dengage needs to be thrown to use the information from widgets.
Widget View is used when the page's widget is actually displayed.
if(recObj.instanceId == "scn_xxx") { // recObj is the recomendationModel object returned from the productView event.
//Any actions related to product's
var interactionId = recObj.interactionId
var instanceId = recObj.instanceId
SegmentifyManager.INSTANCE.sendWidgetView(instanceId,interactionId:interactionId);
}
It is necessary to notify the product productId and which campaign it belongs to when it is clicked on a product in any recommendation.
if(recObj.instanceId == "scn_xxx") { // recObj is the recomendationModel object returned from the productView event.
//Any actions related to product's
var interactionId = productId
var instanceId = recObj.instanceId
SegmentifyManager.INSTANCE.sendClick(instanceId,interactionId:interactionId);
}
It is necessary to notify the productId when it is clicked on a product in any search result.
If identity of the campaign in search response is "BEFORE_SEARCH" then instanceId should be bs_product
.
If identity of the campaign in search response is "SEARCH" then instanceId should be product
.
SegmentifyManager.INSTANCE.sendSearchClickView("product","123456789");
Parameters can be sent with banner operations event is given below (you can also add common parameters):
// Banner impression event
BannerOperationsModel bannerImpressionOperationModel = new BannerOperationsModel();
bannerImpressionOperationModel.setBannerType("impression");
bannerImpressionOperationModel.setTitle("New Season Men Shoes");
bannerImpressionOperationModel.setGroup("Home Page Slider");
bannerImpressionOperationModel.setOrder(1);
SegmentifyManager.INSTANCE.sendBannerImpressionEvent(bannerImpressionOperationModel);
// Banner click event
BannerOperationsModel bannerClickOperationModel = new BannerOperationsModel();
bannerClickOperationModel.setBannerType("click");
bannerClickOperationModel.setTitle("New Season Women Shoes");
bannerClickOperationModel.setGroup("Home Page Slider");
bannerClickOperationModel.setOrder(2);
SegmentifyManager.INSTANCE.sendBannerClickEvent(bannerClickOperationModel);
// Banner update event
BannerOperationsModel bannerUpdateOperationModel = new BannerOperationsModel();
bannerUpdateOperationModel.setBannerType("update");
bannerUpdateOperationModel.setTitle("New Season Women Shoes");
bannerUpdateOperationModel.setGroup("Home Page Slider");
bannerUpdateOperationModel.setOrder(3);
SegmentifyManager.INSTANCE.sendBannerUpdateEvent(bannerUpdateOperationModel);
Parameters can be sent with banner group view event is given below (you can also add common parameters):
// Banner Group View Model
BannerGroupViewModel bannerGroupViewModel = new BannerGroupViewModel();
bannerGroupViewModel.setGroup("Home Page Slider");
// optional parameters
ArrayList<InternalBannerModel> internalBannerModels = new ArrayList<>();
InternalBannerModel internalBannerModel = new InternalBannerModel();
internalBannerModel.setTitle("Gorgeous Duo T-Shirt & Trousers");
internalBannerModel.setOrder(1);
internalBannerModel.setImage("https://www.example.com/gorgeous-duo-tshirt-trousers.jpg");
internalBannerModel.setUrls(new ArrayList<>(Arrays.asList("https://www.example.com/gorgeous-duo-tshirt-trousers")));
internalBannerModels.add(internalBannerModel);
internalBannerModel = new InternalBannerModel();
internalBannerModel.setTitle("Ready to Renew");
internalBannerModel.setOrder(2);
internalBannerModel.setImage("https://www.example.com/ready-to-renew.jpg");
internalBannerModel.setUrls(new ArrayList<>(Arrays.asList("https://www.example.com/ready-to-renew")));
internalBannerModels.add(internalBannerModel);
bannerGroupViewModel.setBanners(internalBannerModels);
// optional parameters end
SegmentifyManager.INSTANCE.sendBannerGroupViewEvent(bannerGroupViewModel);
Parameters can be sent with banner group view event is given below (you can also add common parameters):
BannerGroupViewModel bannerGroupViewModel = new BannerGroupViewModel(); bannerGroupViewModel.setGroup("Home Page Slider"); ArrayList<InternalBannerModel> internalBannerModels = new ArrayList<>(); InternalBannerModel internalBannerModel = new InternalBannerModel(); internalBannerModel.setTitle("Gorgeous Duo T-Shirt & Trousers"); internalBannerModel.setOrder(1); internalBannerModel.setImage("https://www.example.com/gorgeous-duo-tshirt-trousers.jpg"); internalBannerModel.setUrls(new ArrayList<>(Arrays.asList("https://www.example.com/gorgeous-duo-tshirt-trousers"))); internalBannerModels.add(internalBannerModel); internalBannerModel = new InternalBannerModel(); internalBannerModel.setTitle("Ready to Renew"); internalBannerModel.setOrder(2); internalBannerModel.setImage("https://www.example.com/ready-to-renew.jpg"); internalBannerModel.setUrls(new ArrayList<>(Arrays.asList("https://www.example.com/ready-to-renew"))); internalBannerModels.add(internalBannerModel); bannerGroupViewModel.setBanners(internalBannerModels); segmentifyManager.INSTANCE.sendInternalBannerGroupEvent(bannerGroupViewModel);