Understand JSON Responses
MXO returns the following JSON response on the FirstFragment interaction request, which is triggered automatically, by the SDK, based on the Fragment appearing on screen.
In the code example we parse the optimization data
to extract the asset and use the path
as a place on screen where to place this content.
This response is based on the demo app used throughout this exercise.
JSON Response Example
{ "statusCode": 200, "tid": "a00ad08f-e305-8f9c-5c62-1e884543402c", "session": "", "trackers": [], "captures": [], "optimizations": [{ "data": "eyJhY3Rpb25zIjpbeyJuYW1lIjoiUHJvZHVjdCAyQiAtIGNhcmQgaXRlbSIsImFzc2V0Ijp7ImNvbnRlbnQiOiJ7XG4gJm5ic3A7Jm5ic3A7Jm5ic3A7JnF1b3Q7aW1hZ2UmcXVvdDs6ICZxdW90O2h0dHBzOi8vaS5pbWd1ci5jb20vRzN6SG9uNS5wbmcmcXVvdDtcbn0iLCJtaW1lVHlwZSI6ImFwcGxpY2F0aW9uL2pzb24iLCJjb250ZW50VXJsIjpudWxsLCJyZXNwb25zZXMiOlt7ImNvZGUiOiJkR2xrUFdFd01HRmtNRGhtTFdVek1EVXRPR1k1WXkwMVl6WXlMVEZsT0RnME5UUXpOREF5WXl4aFl6MHhNak01T1RZd09USXNZMjUwUFRFeU5EZ3lPRFkwTVN4dmNEMHhNVE14TXpJNU16RXNjSEp2Y0QweE1UQTJPVFE1TVRFc2NuUTlVRTlUU1ZSSlZrVmZRMHhKUTBzc2MyczlUMDVGTFRSRFVWQlZVRmxPTUZjdE9UVXdOU3h3ZGowdE1UVTFOREV5TnpBME16RTRNQSIsInNlbnRpbWVudCI6InBvc2l0aXZlIiwibGFiZWwiOm51bGwsImltYWdlVXJsIjpudWxsLCJ0YXJnZXRVcmwiOm51bGwsInRhcmdldCI6bnVsbH1dfSwicHJvcG9zaXRpb24iOnsiY29kZSI6Im51bGwifX1dfQ==", "path": "card-item", "dataMimeType": "application/json", "directives": "REPLACE" }, { "data": "eyJhY3Rpb25zIjpbeyJuYW1lIjoiUHJvZHVjdCAxQiAtIHRvcCBiYW5uZXIiLCJhc3NldCI6eyJjb250ZW50Ijoie1xuICAgICZxdW90O2ltYWdlJnF1b3Q7OiAmcXVvdDtodHRwczovL2kuaW1ndXIuY29tL0JNbXhYQ2MucG5nJnF1b3Q7XG59IiwibWltZVR5cGUiOiJhcHBsaWNhdGlvbi9qc29uIiwiY29udGVudFVybCI6bnVsbCwicmVzcG9uc2VzIjpbeyJjb2RlIjoiZEdsa1BXRXdNR0ZrTURobUxXVXpNRFV0T0dZNVl5MDFZell5TFRGbE9EZzBOVFF6TkRBeVl5eGhZejB4TWpNNU9UY3dOREVzWTI1MFBURXlORGd5T0RVMk1TeHZjRDB4TVRNeE16STVNekFzY0hKdmNEMHhNVEEyT0RnM056UXNjblE5VUU5VFNWUkpWa1ZmUTB4SlEwc3NjMnM5VDA1RkxUUkRVVkJWVUZsT01GY3RPVFV3TlN4d2RqMHRNVFUxTkRFeU56QTBNekU0TUEiLCJzZW50aW1lbnQiOiJwb3NpdGl2ZSIsImxhYmVsIjpudWxsLCJpbWFnZVVybCI6bnVsbCwidGFyZ2V0VXJsIjpudWxsLCJ0YXJnZXQiOm51bGx9XX0sInByb3Bvc2l0aW9uIjp7ImNvZGUiOiJudWxsIn19XX0=", "path": "top-banner", "dataMimeType": "application/json", "directives": "REPLACE" }] }
Response Elements
Name | Type | Description |
---|---|---|
statusCode | String | 200 success |
tid | String | Unique identifier assigned anonymous customers |
trackers | Array | Array of Activity Capture points associated with an interaction/region |
captures | Array | Array of Attribute Capture points associated with an interaction/region |
optimizations | Array | Array of Optimization points associated with an interaction/region |
JSON Response Parameters
All optimizations are returned as an array.
Optimization object structure:
- data
- Must be base64 decoded.
- path
- Used to determine where the asset is placed on screen.
- Matches the "type" parameter form the JSON shared.
- dataMimeType
- directives
- Used to determine if the content should be placed above or below the target content area, or replace it entirely.