Back

This article describes the number attribute and how to use it in the Universal Data Hub (UDH) product.

In this article:

How it Works

Before you begin, familiarize yourself with the following:

A number attribute stores a numerical property of browsing metrics such as visits, page views, and events. Common examples include Lifetime Value, Order Total Transaction, or Days Since Last Purchase.

The number attribute is available in the following scopes: Event, Visit, Visitor.

Scope-3checks.png

Number Enrichments

Increment or Decrement Number Enrichment

This enrichment modifies a number with a positive value (increment) or a negative value (decrement). The modifying value can be a separate number attribute or a constant value.

For example, to calculate the Lifetime Total Value (LTV) of a visitor's orders use this enrichment to increment the attribute with the value of the order_total attribute each time the purchase event occurs.

Attribute Name: Lifetime Total Value

Initial 121.78
Enriched With order_total: 220.00
Result 341.78

Set Ratio

Set the quotient of two numbers as a new ratio number.

For example, to calculate the Average Cart Items Per Order use this enrichment to set the ratio of the Total Cart Items Purchased attribute to the Total Orders Completed attribute.

Attribute Name: Average Cart Items Per Order

Initial  
Enriched With

Total Cart Items Purchased: 48.00
Total Orders Completed: 3.00

Result 16.00

Set Product

Set the product of two numbers as a new number.

For example, to calculate the coupon_discount_amount, use this enrichment to multiply the order_subtotal by the coupon_discount_percent.

Attribute Namecoupon_discount_amount

Initial  
Enriched With order_subtotal: 42.00
coupon_discount_percent: 0.05
Result 2.10

Set Difference

Set the difference of two numbers as a new number.

Attribute Name: order_subtotal

Initial 42.00
Enriched With order_subtotal: 42.00
coupon_discount_amount: 2.10
Result 39.90

Set Sum

Set to the sum of two numbers.

For example, set order_total to the sum of order_subtotal and order_tax_amount.

Attribute Name: order_total

Initial  
Enriched With order_subtotal: 39.90
order_tax_amount: 3.29
Result 43.19

Set Number

Set the number to a specific number.

For example, set Last Purchase Amount to the value of order_total whenever the purchase event occurs.

Attribute Name: Last Purchase Amount

Initial  
Enriched With order_total:43.19
Result 43.19

Set Difference Between Two Dates

Calculates the elapsed time between two events.  Elapsed time can be expressed as one of the following:

  • Minutes
  • Hours
  • Days
  • Weeks
  • Months

The difference is always stored as a positive value, so the dates can be set in any order.

For example, to calculate Days Since Last Purchase as the difference in days between Last Purchase Date and Current Visit Date. 

While date attributes are stored as Unix timestamps, these examples use formatted dates for readability.

Attribute NameDays Since Last Purchase

Initial  
Enriched With Last Purchase Date: "2018/10/30"
Current Visit Date: "2019/11/01"
Result 367

Set Rolling Average Based on Timeline

The rolling average is the arithmetic mean of numerical values captured over time. These values come from number and tally attributes that are collected as entries in a timeline. The timeline's expiration determines which entries can be factored into the final average. If there is not an expiration date, it is a simple average solution. For detailed information, see Number/Tally Enrichment: Set Rolling Average Based on Timeline.

Attribute Name: Average Order Value

Initial  
Enriched With [20.00, 30.00, 40.00, 50.00]
Result 35.00

Set Rolling Sum Based on Timeline

A rolling sum is the aggregate of numerical values in a number or tally attribute that are captured as entries in a timeline. The timeline's expiration determines which entries can be factored in during the aggregation. For detailed information, see Number/Tally Enrichment: Set Rolling Sum Based on Timeline.

Attribute Name: Total Order Value

Initial  
Enriched With [10.00, 20.00, 30.00, 40.00, 50.00]
Result 150.00

Set Number to the Number of Entries in Timeline

Set the number to the number of entries in a timeline.

Attribute Name: Total Order Count

Initial  
Enriched With [10.00, 20.00, 30.00, 40.00, 50.00]
Result 5.00

Set Number to Tally Value

Set the number to a specific value within the tally. Specify the tally attribute and the name of the entry in the tally. For example, a tally for Site Category Views might have an entry for "Shoes".

Attribute Name: Shoe Category View Count

Initial  
Enriched With Site Category Views: {"Shoes": 42}
Result 42

Set Number to the Count of Items in Tally

Set the attribute to the number of entries in a tally. For example, a tally for Site Category Views might have three entries in it.

Attribute Name: Number of Categories Viewed

Initial  
Enriched With

{
  "Shoes": 42,
  "Shirts": 11,
  "Pants": 8

Result 3.00

Set Number to the Count of Items in Set of Strings

Set the number to the count of items in a set of strings. For example, a set of strings Active Browser Types might have 3 entries.

Attribute Name: Number of Active Browser Types

Initial  
Enriched With ["Firefox", "Safari", "Chrome"]
Result 3.00

Set Number to Tally's Rolling Max Based on a Timeline

Set the number to the rolling maximum of another number in a tally captured within a timeline.

Attribute Name: Highest Order Value

Initial  
Enriched With [10.00, 20.00, 30.00, 40.00, 50.00]
Result 50.00

Set Number to Change in Number

Set this attribute to the difference between it and another attribute since the last event. For example, use this enrichment to capture the difference between a previous order amount and the current order amount. To set an attribute named Change in Order Value, set it to the change in order_subtotal since the previous order. 

Attribute Name: Change in Order Value

Initial 30.00
Enriched With order_subtotal: 42.00
Result 12.00

Set Number to Change in Date

Set this attribute to the change in value of the selected value between this event and the last event. For example, use this enrichment to capture the change in months of the Last Purchase Date date attribute each time a purchase occurs. 

The change in date can be expressed as one of the following:

  • Minutes
  • Hours
  • Days
  • Weeks
  • Months

Attribute Name: Months Since Last Purchase

Initial
Enriched With

Last Purchase Date (last event): "10/31/2019"
Last Purchase Date (this event): "12/31/2019"

Result 2 (months)

Set to the Number of Items in an Array

Set to the number of items in an array. For example, to store the number of products in the cart, use this enrichment to capture the number of items in the cart_product_id array.

Attribute Name: num_cart_items

Initial  
Enriched With product_id: ["prod123", "prod456"]
Result 2.00