ProcessingExpressions

Expressions

The expression language is used throughout pipeline configurations for filter conditions, computed fields, and conditional mappings. It provides a SQL-like syntax for referencing event fields, applying operators, and calling functions.

Field References

Fields are referenced using dot notation starting from the event root:

ReferenceDescription
event.typeEvent type (track, page, identify, group)
event.eventEvent name (e.g. "Purchase")
event.userIdKnown user ID
event.anonymousIdAnonymous ID
event.properties.revenueEvent property
event.traits.emailUser trait
event.context.page.urlPage URL from context
event.context.geo.countryEnriched geolocation
event.context.device.browserParsed device data
event.context.session.idSession identifier
event.vendorIds.ga4_client_idVendor-specific identifier
event.clickIds.gclidCaptured click ID

Array Access

Access array elements by index or iterate with wildcards:

event.properties.products[0].name      -- first product name
event.properties.products[*].product_id -- all product IDs (returns array)

Nested Fields

There is no depth limit on nesting:

event.context.campaign.source
event.properties.items[0].variant.color

Operators

Comparison Operators

OperatorDescriptionExample
=Equalevent.type = 'track'
!=Not equalevent.type != 'identify'
>Greater thanevent.properties.revenue > 100
<Less thanevent.properties.quantity < 10
>=Greater than or equalevent.properties.revenue >= 50
<=Less than or equalevent.properties.quantity <= 100

Logical Operators

OperatorDescriptionExample
ANDLogical ANDevent.type = 'track' AND event.event = 'Purchase'
ORLogical ORevent.event = 'Purchase' OR event.event = 'Checkout'
NOTLogical NOTNOT event.properties.is_test

Set Operators

OperatorDescriptionExample
INValue in setevent.event IN ('Purchase', 'Add to Cart', 'Checkout')
NOT INValue not in setevent.context.geo.country NOT IN ('CN', 'RU')

Pattern Matching

OperatorDescriptionExample
LIKESQL-like pattern match (% wildcard)event.context.page.url LIKE '%/checkout%'
NOT LIKENegated pattern matchevent.context.userAgent NOT LIKE '%bot%'

Operator Precedence

From highest to lowest:

  1. NOT
  2. Comparison operators (=, !=, >, <, >=, <=)
  3. IN, NOT IN, LIKE, NOT LIKE
  4. AND
  5. OR

Use parentheses to override precedence:

(event.event = 'Purchase' OR event.event = 'Refund') AND event.properties.revenue > 0

Functions

String Functions

FunctionDescriptionExample
LOWER(value)Convert to lowercaseLOWER(event.traits.email)
UPPER(value)Convert to uppercaseUPPER(event.properties.currency)
TRIM(value)Remove leading/trailing whitespaceTRIM(event.traits.name)
CONCAT(a, b, ...)Concatenate stringsCONCAT(event.traits.firstName, ' ', event.traits.lastName)
SUBSTRING(value, start, length)Extract substringSUBSTRING(event.properties.sku, 0, 3)
REPLACE(value, search, replace)Replace occurrencesREPLACE(event.event, ' ', '_')
LENGTH(value)String lengthLENGTH(event.traits.email)

Null Handling

FunctionDescriptionExample
COALESCE(a, b, ...)Return first non-null valueCOALESCE(event.userId, event.anonymousId, 'unknown')
IS_NULL(value)Check if null/missingIS_NULL(event.userId)
IS_NOT_NULL(value)Check if presentIS_NOT_NULL(event.properties.revenue)

Hash Functions

FunctionDescriptionExample
HASH_SHA256(value)SHA-256 hash (hex)HASH_SHA256(LOWER(TRIM(event.traits.email)))
HASH_MD5(value)MD5 hash (hex)HASH_MD5(event.traits.email)

Date/Time Functions

FunctionDescriptionExample
NOW()Current Unix timestamp (seconds)NOW()
TO_UNIX(value)Convert ISO 8601 to Unix secondsTO_UNIX(event.timestamp)
TO_UNIX_MS(value)Convert ISO 8601 to Unix millisecondsTO_UNIX_MS(event.timestamp)
TO_ISO(value)Convert Unix seconds to ISO 8601TO_ISO(event.properties.created_at)

Numeric Functions

FunctionDescriptionExample
ROUND(value, decimals)Round to N decimalsROUND(event.properties.revenue, 2)
FLOOR(value)Round downFLOOR(event.properties.revenue)
CEIL(value)Round upCEIL(event.properties.revenue)
ABS(value)Absolute valueABS(event.properties.amount)
MIN(a, b)Minimum of two valuesMIN(event.properties.quantity, 100)
MAX(a, b)Maximum of two valuesMAX(event.properties.revenue, 0)

Type Functions

FunctionDescriptionExample
TO_STRING(value)Convert to stringTO_STRING(event.properties.quantity)
TO_NUMBER(value)Convert to numberTO_NUMBER(event.properties.price)
TO_BOOLEAN(value)Convert to booleanTO_BOOLEAN(event.properties.is_active)
TYPE_OF(value)Return the type as a stringTYPE_OF(event.properties.revenue)

Examples

Filter: Only Purchase Events

- type: filter
  condition: "event.type = 'track' AND event.event = 'Purchase'"

Filter: Events with Revenue

- type: filter
  condition: "IS_NOT_NULL(event.properties.revenue) AND event.properties.revenue > 0"

Filter: Specific Countries

- type: filter
  condition: "event.context.geo.country IN ('US', 'CA', 'GB', 'AU')"

Filter: URL Pattern

- type: filter
  condition: "event.context.page.url LIKE '%/checkout%' OR event.context.page.url LIKE '%/purchase%'"

Compute: Full Name

- type: compute
  fields:
    user_data.name:
      expression: "CONCAT(COALESCE(event.traits.firstName, ''), ' ', COALESCE(event.traits.lastName, ''))"
      type: string

Compute: Hashed Email (for Meta CAPI)

- type: compute
  fields:
    user_data.em:
      expression: "HASH_SHA256(LOWER(TRIM(event.traits.email)))"
      type: string

Compute: Revenue in Cents to Dollars

- type: compute
  fields:
    custom_data.value:
      expression: "ROUND(event.properties.amount_cents / 100, 2)"
      type: number

Compute: Conditional Value

- type: compute
  fields:
    events[0].params.value:
      expression: "COALESCE(event.properties.revenue, event.properties.total, event.properties.amount, 0)"
      type: number

Compute: UTM Source Normalisation

- type: compute
  fields:
    events[0].params.campaign_source:
      expression: "LOWER(COALESCE(event.context.campaign.source, 'direct'))"
      type: string

Null Behaviour

Expressions follow SQL-style null semantics:

ExpressionResult
NULL = 'value'false
NULL != 'value'false
NULL > 0false
NULL AND truefalse
NULL OR truetrue
NOT NULLNULL
COALESCE(NULL, 'fallback')'fallback'

When a field reference points to a field that does not exist on the event, it evaluates to NULL. Use COALESCE() or IS_NULL() / IS_NOT_NULL() to handle missing fields gracefully.

Type Coercion

The expression engine performs automatic type coercion in these cases:

ContextCoercion
Comparison with string literalValue is coerced to string
Comparison with number literalValue is coerced to number
Arithmetic operationsBoth operands coerced to number
CONCAT() argumentsAll arguments coerced to string
Boolean context (filter conditions)Truthy/falsy evaluation

If coercion fails (e.g. converting "abc" to a number), the expression evaluates to NULL.