Products Variable

Products Variable

The products variable cannot be set using processing rules. In the mobile SDK, you must use a special syntax within the context data parameter to set products directly on the server call.

To set the products variable, set a context data key to "&&products", and set the value using the syntax defined for the products variable:

cdata.put("&&products", "Category;Product;Quantity;Price[,Category;Product;Quantity;Price]");

For example:

//create a context data dictionary
HashMap cdata = new HashMap<String, Object>();

// add products, a purchase id, a purchase context data key, and any other data you want to collect.
// Note the special syntax for products
cdata.put("&&products", ";Running Shoes;1;69.95,;Running Socks;10;29.99");
cdata.put("myapp.purchase", "1");
cdata.put("myapp.purchaseid", "1234567890");

// send the tracking call - use either a trackAction or TrackState call.
// trackAction example:
Analytics.trackAction("purchase", cdata);
// trackState example:
Analytics.trackState("Order Confirmation", cdata);

Note that products is set directly on the image request, and the other variables are set as context data:

All context data variables must be mapped using processing rules:

You do not need to map the products variable using processing rules since it is set directly on the image request by the SDK.

  • Products Variable with Merchandising eVars and Product-Specific Events
    An example of the products variable with Merchandising eVars and product-specific events.
  • Parent topic: Analytics