Criteo - Apsalar SDK Implementation Guide

Last Updated: Aug 24, 2015 04:54PM PDT

Apsalar SDK Implementation for Criteo Events

The following guide contains contains examples on how the required Criteo values should be mapped and implemented in the Apsalar SDK.  Please note that product ID values need to be registered with your Criteo representative before they can be accepted in Criteo.  For any questions or more details on Criteo event requirements, contact your Criteo representative along with support@apsalar.com.

viewListing

iOS SDK

For a listing with a single product
NSArray *contents = @[@"Item1"];
[Apsalar event:@"viewListing" withArgs:[NSDictionary dictionaryWithObjectsAndKeys:
   contents,@"viewListing", 
   nil]]; 
For a listing with multiple products
NSArray *contents = @[@"Item1", @"Item2", @"Item3"];
[Apsalar event:@"viewListing" withArgs:[NSDictionary dictionaryWithObjectsAndKeys:
  contents,@"viewListing", 
  nil]]; 

Android SDK

For a listing with a single product
JSONArray list = new JSONArray();
list.put("UPC-018627610014");
Apsalar.event("viewListing", "viewListing", list);
For a listing with multiple products
JSONArray list = new JSONArray();
list.put("UPC-018627610014");
list.put("UPC-070271003758");
list.put("ISBN13-978-0-596-51774-8");
Apsalar.event("viewListing", "viewListing", list);

viewHome

Criteo's viewHome event is supported through Apsalar's "Session Start" event.  Implement Apsalar's "Session Start" normally as documented in our iOS and Android SDK guide.

viewProduct

iOS SDK

Note the escape character required around the double quotations
[Apsalar eventWithArgs:@"viewProduct",
   @"viewProduct", @"\"UPC-018627610014\""]; 

Android SDK

Note the escape character required around the double quotations
Apsalar.event("viewProduct", "viewProduct", "\"UPC-018627610014\"");

viewBasket

iOS SDK

For a basket with a single product
NSDictionary *item1 = [NSDictionary dictionaryWithObjectsAndKeys:
   @"UPC-018627610014", @"id",
   [NSNumber numberWithInt:2], @"quantity",
   [NSNumber numberWithDouble:8.99], @"price",
   nil];

NSArray *contents = [NSArray arrayWithObjects:item1, nil];
[Apsalar event:@"viewBasket" withArgs:[NSDictionary dictionaryWithObjectsAndKeys:
   contents, @"viewBasket",
   [NSNumber numberWithDouble:8.99], @"total",
   @"USD", @"currency",
   @"A556740089", @"member_id", nil]];

For a basket with multiple products
NSDictionary *item1 = [NSDictionary dictionaryWithObjectsAndKeys:
   @"UPC-018627610014", @"id",
   [NSNumber numberWithInt:2], @"quantity",
   [NSNumber numberWithDouble:8.99], @"price",
   nil];

NSDictionary *item2 = [NSDictionary dictionaryWithObjectsAndKeys:
   @"UPC-070271003758", @"id",
   [NSNumber numberWithInt:1], @"quantity",
   [NSNumber numberWithDouble:15.99], @"price",
   nil];

NSDictionary *item3 = [NSDictionary dictionaryWithObjectsAndKeys:
   @"ISBN13-978-0-596-51774-8", @"id",
   [NSNumber numberWithInt:1], @"quantity",
   [NSNumber numberWithDouble:45.79], @"price",
   nil];

NSArray *contents = [NSArray arrayWithObjects:item1, item2, item3, nil];
[Apsalar event:@"viewBasket" withArgs:[NSDictionary dictionaryWithObjectsAndKeys:
   contents, @"viewBasket",
   [NSNumber numberWithDouble:79.76], @"total",
   @"USD", @"currency",
   @"A556740089", @"member_id", nil]];

Android SDK

For a basket with a single product
try {
    JSONArray contents = new JSONArray();
    JSONObject item1 = new JSONObject();

    item1.put("id", "UPC-018627610014");
    item1.put("quantity", 2);
    item1.put("price", 8.99);
    contents.put(item1);

    JSONObject viewBasket = new JSONObject();
    viewBasket.put("viewBasket", contents);
    viewBasket.put("total", 17.98);
    viewBasket.put("currency", "USD");
    viewBasket.put("member_id", "A556740089");

    Apsalar.eventJSON("viewBasket", viewBasket);
}
catch (JSONException e) {
    android.util.Log.e("Now", "JSON Exception in cart");
}
For a basket with multiple products
try {
    JSONArray contents = new JSONArray();
    JSONObject item1 = new JSONObject();

    item1.put("id", "UPC-018627610014");
    item1.put("quantity", 2);
    item1.put("price", 8.99);
    contents.put(item1);

    JSONObject item2 = new JSONObject();
    item2.put("id", "UPC-070271003758");
    item2.put("quantity", 1);
    item2.put("price", 15.99);
    contents.put(item2);

    JSONObject item3 = new JSONObject();
    item3.put("id", "ISBN13-978-0-596-51774-8");
    item3.put("quantity", 1);
    item3.put("price", 15.99);
    contents.put(item3);

    JSONObject viewBasket = new JSONObject();
    viewBasket.put("viewBasket", contents);
    viewBasket.put("total", 63.96);
    viewBasket.put("currency", "USD");
    viewBasket.put("member_id", "A556740089");

    Apsalar.eventJSON("viewBasket", viewBasket);
}
catch (JSONException e) {
    android.util.Log.e("Now", "JSON Exception in cart");
}
support@apsalar.com
http://assets3.desk.com/
apsalarinc
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
Invalid characters found
/customer/en/portal/articles/autocomplete