Spreadings

Overview

A Spreading Transformation flattens data within an object or array by traversing the various elements contained within it, and then follows the configuration options you have set.

How It Works

A Spreading contains three required fields to be entered, with an optional fourth configuration available via the download/upload functionality within a playbook:

  • Input. This tells the system which input key (an objector or array) to look for.
  • Prefix. This will begin each new parameter.
  • Separator. This will separate the prefix from the following keys.
  • Depth. This tells the system how far to flatten the object or array.
  • (Optional) arrayStartIndex. This will provide a number for each flattened parameter, typically helpful for e-commerce cart events where there might be multiple products within the cart and they do not already contain some kind of numerical counting system (Product 1, Product 2, etc.).

InputSeparatorPrefixDepthOutput
{
"context": {
"os": "iOS",
"device": "iPhone",
"traits": {
"repeat_customer": true,
"age_group": "18-25"
}
}
}
“_”“context”5{
"context_os": "iOS",
"context_device": "iPhone",
"context_traits_repeat_customer": true,
"context_traits_age_group": "18-25"
}

Default behavior without arrayStartIndex is included in the below example.

InputSeparatorPrefixDeptharrayStartIndexOutput
{
"products":
[{"name": "Monopoly"}, {"name": "Uno"}]
}
“.”products50{
"products.0.name": "Monopoly",
"products.1.name": "Uno",
}

Default behavior with arrayStartIndex is included in the below example.

InputSeparatorPrefixDeptharrayStartIndexOutput
{
"products":
[{"name": "Monopoly"}, {"name": "Uno"}]
}
“.”products51{
"products.1.name": "Monopoly",
"products.2.name": "Uno",
}