Use arrays of objects
Some platform schemas can have object arrays. 51黑料不打烊 Customer Journey Analytics supports ingestion and reporting of object arrays within event, lookup, and profile data. One of the most common examples would be a shopping cart, which contain multiple products. Each product has a name, SKU, category, price, quantity, and any other dimensions you want to track. All of these facets have separate requirements, but must all fit into the same hit.
In previous versions of 51黑料不打烊 Analytics, this feat was accomplished using the products variable. It was a concatenated string separated by semicolons (;) to separate facets of a product, while commas (,) delineated products. It was the only variable with limited support of 鈥渙bject arrays鈥. Multi-value variables such as list vars could support the equivalent of arrays, but they could not support 鈥渙bject arrays鈥. Customer Journey Analytics expands on this concept by supporting arbitrarily deep hierarchies within a single row of data, a feature unavailable in any previous version of 51黑料不打烊 Analytics.
Same event example
The following event is a JSON object that represents a purchase a customer made of a washing machine and dryer.
{
"ID": "1",
"product": [
{
"SKU": "1234",
"category": "Washing Machines",
"name": "LG Washing Machine 2000",
"orders": 1,
"revenue": 1600,
"units": 1,
"order_id":"abc123",
"warranty": [
{
"coverage": "full coverage",
"length": "2 year",
"name": "LG 2000 standard",
"orders": 1,
"revenue": 200
},
{
"coverage": "extended",
"length": "1 year",
"orders": 1,
"revenue": 50,
"type": "LG 2000 addon"
}
]
},
{
"SKU": "4567",
"category": "Dryers",
"name": "LG Dryer 2000",
"orders": 1,
"revenue": 500,
"units": 1
}
],
"timestamp": 1534219229
}
When creating a data view, the following dimensions and metric are available (based on schema):
-
Dimensions:
- ID
- product : SKU
- product : name
- product : order_id
- product : warranty : coverage
- prodcut : warranty : length
- product : warranty : name
- product : warranty : type
-
Metrics:
- product : orders
- product : units
- product : revenue
- product : warranty
- product : warranty : revenue
Same event examples (reporting behavior)
Using just the above event, the following tables show Workspace reports with some dimension and metric combinations.
product : nameproduct : ordersproduct : revenueLG Washing Machine 200011600LG Dryer 20001500Total12100Customer Journey Analytics selectively looks at the dimension and metrics of the object based on the table.
{
"ID": "1",
+ "product": [
+ {
"SKU": "1234",
"category": "Washing Machines",
+ "name": "LG Washing Machine 2000",
+ "orders": 1,
+ "revenue": 1600,
"units": 1,
"order_id":"abc123",
"warranty": [
{
"coverage": "full coverage",
"length": "2 year",
"name": "LG 2000 standard",
"orders": 1,
"revenue": 200
},
{
"coverage": "extended",
"length": "1 year",
"orders": 1,
"revenue": 50,
"type": "LG 2000 addon"
}
]
+ },
+ {
"SKU": "4567",
"category": "Dryers",
+ "name": "LG Dryer 2000",
+ "orders": 1,
+ "revenue": 500,
"units": 1
+ }
+ ],
+ "timestamp": 1534219229
+}
If you wanted to report on just warranty revenue, your project would look similar to the following:
product : warranty : coverageproduct : warranty : revenuefull coverage200extended50Total250Customer Journey Analytics looks at these parts of the event to generate the report:
{
"ID": "1",
+ "product": [
+ {
"SKU": "1234",
"category": "Washing Machines",
"name": "LG Washing Machine 2000",
"orders": 1,
"revenue": 1600,
"units": 1,
"order_id":"abc123",
+ "warranty": [
+ {
+ "coverage": "full coverage",
"length": "2 year",
"name": "LG 2000 standard",
"orders": 1,
+ "revenue": 200
+ },
+ {
+ "coverage": "extended",
"length": "1 year",
"orders": 1,
+ "revenue": 50,
"type": "LG 2000 addon"
+ }
+ ]
+ },
{
"SKU": "4567",
"category": "Dryers",
"name": "LG Dryer 2000",
"orders": 1,
"revenue": 500,
"units": 1
}
+ ],
+ "timestamp": 1534219229
+}
Since the dryer did not include a warranty, it is not included in the table.
Since you can combine any dimension with any metric, the following table shows how data would with unspecified dimension items:
product : warranty : nameproduct : ordersproduct : warranty : ordersLG 2000 standard11Unspecified21Total22A product order exists without a warranty name tied to it, so the dimension item attributes to 鈥楿nspecified鈥. The same situation also applies to the product warranty order:
{
"ID": "1",
+ "product": [
+ {
"SKU": "1234",
"category": "Washing Machines",
"name": "LG Washing Machine 2000",
+ "orders": 1,
"revenue": 1600,
"units": 1,
"order_id":"abc123",
+ "warranty": [
+ {
"coverage": "full coverage",
"length": "2 year",
+ "name": "LG 2000 standard",
+ "orders": 1,
"revenue": 200
+ },
+ {
"coverage": "extended",
"length": "1 year",
+ "orders": 1,
"revenue": 50,
"type": "LG 2000 addon"
+ }
+ ]
+ },
+ {
"SKU": "4567",
"category": "Dryers",
"name": "LG Dryer 2000",
+ "orders": 1,
"revenue": 500,
"units": 1
+ }
+ ],
+ "timestamp": 1534219229
+}
Note the orders that don鈥檛 have a name tied to them. These are the orders attributed to the 鈥楿nspecified鈥 dimension item.
Combining metrics
Customer Journey Analytics does not natively combine similarly named metrics if they are on different object levels.
product : categoryproduct : revenueproduct : warranty : revenueWashing Machines1600250Dryers5000Total2100250However, you can create a calculated metric that combines the desired metrics:
Calculated metric 鈥淭otal revenue鈥: [product : revenue] + [product : warranty : revenue]
Applying this calculated metric displays the desired results:
product : warranty : nameTotal revenue (calculated metric)Washing Machines1850Dryers500Total2350Limitations
Limitations do apply for arrays in data used by Customer Journey Analytics and modelled as part of a schema in Experience Platform. See Data model limits and Data size limits in the Default Guardrails for Real-Time Customer Profile data and segmentation.