Attribute Data Type: Array

Attribute Data Type: Array

by Community Manager ‎07-24-2018 08:51 AM - edited ‎07-24-2018 02:08 PM (281 Views)

This article explains how to use the data types array of numbers, array of strings, and array of booleans in the Universal Data Hub (UDH). Arrays are used to store a list of values of the same type.

In this article:

Table of Contents Placeholder

Overview

Arrays are used in the data layer and in the UDH to store a list of values. Whereas a string or number attribute can only contain a single value e.g., "Home Page" or 12.95, an array can contain multiple values e.g. ["Pants", "Shirts"] or [5.99, 12.95]. For example, arrays are used for product details when tracking purchase transactions. A purchase often contains more than one product, so arrays are used to store the ID, name, price, and quantity of each product in the transaction.

Arrays can contain duplicate values.

The following are available as event, visit, and visitor attributes:

  • Array of Strings
  • Array of Numbers
  • Array of Booleans

Arrays are represented in JSON format as comma delimited values surrounded by square brackets, so this syntax will be used in all of the examples.

Array with values:

  •  ["Pants", "Shirts", "Shoes"]
  •  [2, 4, 6]
  •  [true, false, false]

Empty array: []

Array of Strings Enrichments

The array of strings attribute stores a list of text values. 

All non-string values are ignored.

Add a String

This enrichment adds a value to the array. The added attribute can only be a string, iQ variable, or Omnichannel attribute.

Starting Value  ["Pants"]
Enriched With  "Shirts"
Resulting Value  ["Pants", "Shirts"]

Add an Array of Strings

This enrichment adds all the values from one array to the array. The added attribute can only be an array of strings or iQ variable.

Starting Value  ["Pants"]
Enriched With  ["Shirts", "Shoes"]
Resulting Value  ["Pants", "Shirts", "Shoes"]

Difference Between Two Arrays

This enrichment takes two arrays as input, looks for values that occur in one and not the other, and inserts them into the array. In this example, values from "Wishlist Products" that do not also occur in "Purchased Products" are added to the resulting array.

Starting Value  []
Enriched With

Difference between:

Wishlist Products
 ["Pants", "Shirt", "Shoes", "Belt"]

and

Purchased Products
 ["Pants", "Shirt"]

Resulting Value  ["Shoes", "Belt"]

Reset

This enrichment removes all values from the array.

Starting Value  ["Shoes", "Belt"]
Resulting Value  []

Lowercase

This enrichment lowercases every value in the array.

Starting Value  ["Shoes", "Belt"]
Resulting Value  ["shoes", "belt"]


Array of Numbers

The array of numbers attribute stores a list of numeric values. 

String representations of numbers ("0", "123", "12.95") will be parsed to their numeric values. All other non-numeric values are ignored.

Add a Number

This enrichment adds a number value to the array. The added attribute can only be a number, iQ variable, or Omnichannel attribute.

Starting Value  [12.95]
Enriched With  5.99
Resulting Value  [12.95, 5.99]

Add an Array of Numbers

This enrichment adds all the values from one array to the array. The added attribute can only be an array of numbers or iQ variable.

Starting Value  [12.95]
Enriched With  [5.99, 10.00]
Resulting Value  [12.95, 5.99, 10.00]

Reset

This enrichment removes all values from the array.

Starting Value  [12.95, 5.99]
Resulting Value  []

Set Array of Numbers to be the Difference of Two Arrays

This enrichment takes two arrays as input, looks for values that occur in one and not the other, and inserts them into the array. In this example, values from "Gift Card Amounts" that do not also occur in "Gift Cards Purchased" are added to the resulting array.

Starting Value  []
Enriched With

Difference between:

Gift Card Amounts
 [5, 10, 25, 50, 100, 250]

and

Gift Cards Purchased
 [25, 50]

Resulting Value  [5, 10, 100, 250]


Array of Booleans

The array of booleans attribute stores a list of true/false values. 

The strings "true" and "false" (any mix of upper/lowercase) will be converted to their respective boolean values. All other non-boolean values are ignored.

Add a Boolean

This enrichment adds a value to the array. The added attribute can only be a boolean, iQ variable, or Omnichannel attribute. 

Starting Value  [true]
Enriched With  false
Resulting Value  [true, false]

Add an Array of Booleans

This enrichment adds all the values from one array to the array. The added attribute can only be a array of booleans or iQ variable.

Starting Value  [true]
Enriched With  ["false", "True"]
Resulting Value  [true, false, true]

Reset

This enrichment removes all values from the array.

Starting Value  [true, false, true]
Resulting Value  []