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:
| Reference | Description |
|---|---|
event.type | Event type (track, page, identify, group) |
event.event | Event name (e.g. "Purchase") |
event.userId | Known user ID |
event.anonymousId | Anonymous ID |
event.properties.revenue | Event property |
event.traits.email | User trait |
event.context.page.url | Page URL from context |
event.context.geo.country | Enriched geolocation |
event.context.device.browser | Parsed device data |
event.context.session.id | Session identifier |
event.vendorIds.ga4_client_id | Vendor-specific identifier |
event.clickIds.gclid | Captured 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.colorOperators
Comparison Operators
| Operator | Description | Example |
|---|---|---|
= | Equal | event.type = 'track' |
!= | Not equal | event.type != 'identify' |
> | Greater than | event.properties.revenue > 100 |
< | Less than | event.properties.quantity < 10 |
>= | Greater than or equal | event.properties.revenue >= 50 |
<= | Less than or equal | event.properties.quantity <= 100 |
Logical Operators
| Operator | Description | Example |
|---|---|---|
AND | Logical AND | event.type = 'track' AND event.event = 'Purchase' |
OR | Logical OR | event.event = 'Purchase' OR event.event = 'Checkout' |
NOT | Logical NOT | NOT event.properties.is_test |
Set Operators
| Operator | Description | Example |
|---|---|---|
IN | Value in set | event.event IN ('Purchase', 'Add to Cart', 'Checkout') |
NOT IN | Value not in set | event.context.geo.country NOT IN ('CN', 'RU') |
Pattern Matching
| Operator | Description | Example |
|---|---|---|
LIKE | SQL-like pattern match (% wildcard) | event.context.page.url LIKE '%/checkout%' |
NOT LIKE | Negated pattern match | event.context.userAgent NOT LIKE '%bot%' |
Operator Precedence
From highest to lowest:
NOT- Comparison operators (
=,!=,>,<,>=,<=) IN,NOT IN,LIKE,NOT LIKEANDOR
Use parentheses to override precedence:
(event.event = 'Purchase' OR event.event = 'Refund') AND event.properties.revenue > 0Functions
String Functions
| Function | Description | Example |
|---|---|---|
LOWER(value) | Convert to lowercase | LOWER(event.traits.email) |
UPPER(value) | Convert to uppercase | UPPER(event.properties.currency) |
TRIM(value) | Remove leading/trailing whitespace | TRIM(event.traits.name) |
CONCAT(a, b, ...) | Concatenate strings | CONCAT(event.traits.firstName, ' ', event.traits.lastName) |
SUBSTRING(value, start, length) | Extract substring | SUBSTRING(event.properties.sku, 0, 3) |
REPLACE(value, search, replace) | Replace occurrences | REPLACE(event.event, ' ', '_') |
LENGTH(value) | String length | LENGTH(event.traits.email) |
Null Handling
| Function | Description | Example |
|---|---|---|
COALESCE(a, b, ...) | Return first non-null value | COALESCE(event.userId, event.anonymousId, 'unknown') |
IS_NULL(value) | Check if null/missing | IS_NULL(event.userId) |
IS_NOT_NULL(value) | Check if present | IS_NOT_NULL(event.properties.revenue) |
Hash Functions
| Function | Description | Example |
|---|---|---|
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
| Function | Description | Example |
|---|---|---|
NOW() | Current Unix timestamp (seconds) | NOW() |
TO_UNIX(value) | Convert ISO 8601 to Unix seconds | TO_UNIX(event.timestamp) |
TO_UNIX_MS(value) | Convert ISO 8601 to Unix milliseconds | TO_UNIX_MS(event.timestamp) |
TO_ISO(value) | Convert Unix seconds to ISO 8601 | TO_ISO(event.properties.created_at) |
Numeric Functions
| Function | Description | Example |
|---|---|---|
ROUND(value, decimals) | Round to N decimals | ROUND(event.properties.revenue, 2) |
FLOOR(value) | Round down | FLOOR(event.properties.revenue) |
CEIL(value) | Round up | CEIL(event.properties.revenue) |
ABS(value) | Absolute value | ABS(event.properties.amount) |
MIN(a, b) | Minimum of two values | MIN(event.properties.quantity, 100) |
MAX(a, b) | Maximum of two values | MAX(event.properties.revenue, 0) |
Type Functions
| Function | Description | Example |
|---|---|---|
TO_STRING(value) | Convert to string | TO_STRING(event.properties.quantity) |
TO_NUMBER(value) | Convert to number | TO_NUMBER(event.properties.price) |
TO_BOOLEAN(value) | Convert to boolean | TO_BOOLEAN(event.properties.is_active) |
TYPE_OF(value) | Return the type as a string | TYPE_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: stringCompute: Hashed Email (for Meta CAPI)
- type: compute
fields:
user_data.em:
expression: "HASH_SHA256(LOWER(TRIM(event.traits.email)))"
type: stringCompute: Revenue in Cents to Dollars
- type: compute
fields:
custom_data.value:
expression: "ROUND(event.properties.amount_cents / 100, 2)"
type: numberCompute: Conditional Value
- type: compute
fields:
events[0].params.value:
expression: "COALESCE(event.properties.revenue, event.properties.total, event.properties.amount, 0)"
type: numberCompute: UTM Source Normalisation
- type: compute
fields:
events[0].params.campaign_source:
expression: "LOWER(COALESCE(event.context.campaign.source, 'direct'))"
type: stringNull Behaviour
Expressions follow SQL-style null semantics:
| Expression | Result |
|---|---|
NULL = 'value' | false |
NULL != 'value' | false |
NULL > 0 | false |
NULL AND true | false |
NULL OR true | true |
NOT NULL | NULL |
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:
| Context | Coercion |
|---|---|
| Comparison with string literal | Value is coerced to string |
| Comparison with number literal | Value is coerced to number |
| Arithmetic operations | Both operands coerced to number |
CONCAT() arguments | All 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.