Filters

Filter syntax for widget queries

Basic filter object

Attach filter to a widget to narrow matching events.

widget.metric({
  id: 'pricing_visitors',
  label: 'Pricing Visitors',
  event: '$pageview',
  aggregation: 'unique_users',
  filter: {
    $pathname: '/pricing',
  },
})

Supported operators

PatternMeaningExample
Primitive valueEquals{ plan: 'pro' }
$inIn list{ plan: { $in: ['pro', 'enterprise'] } }
$gteGreater than / equal{ amount: { $gte: 100 } }
$lteLess than / equal{ amount: { $lte: 500 } }

Examples

// Campaign traffic only
filter: { $utm_source: 'google' }

// Multi-country
filter: { $geo_country: { $in: ['US', 'CA', 'GB'] } }

// Revenue threshold
filter: { amount: { $gte: 100 } }

Funnel step filters

widget.funnel({
  id: 'pricing_to_signup',
  title: 'Pricing to Signup',
  steps: [
    {
      event: '$pageview',
      label: 'Pricing Page',
      filter: { $pathname: '/pricing' },
    },
    {
      event: 'signup_completed',
      label: 'Signup Complete',
      filter: { plan: 'pro' },
    },
  ],
})

Current query translation limits

  • Current runtime query translation uses the first filter condition only
  • FilterGroup and nested AND/OR trees are currently ignored by the query layer
  • Operators outside eq/in/gte/lte are not translated today

Next Steps