Funnels: Evaluate data from a series of related events

With NRQL, you can use funnels to evaluate sets of related actions. The actions generally share a relationship via an identifier such as a user ID or session ID.

Why it matters

NRQL funnel functions can answer questions like, "Of the people that completed step A, how many also completed step B, and of the people that completed steps A and B, how many also completed step C?"

For example, at New Relic, we could use funnel to track the number of users who completed these steps:

  1. Visited the New Relic One marketing page.
  2. Signed up for an account.
  3. Created a dashboard.

Funnel query structure

Here's the structure of a simple NRQL funnel query:

FROM DATA_TYPE 
  SELECT funnel(AN_ATTRIBUTE, ACTION_A, ACTION_B) 
  SINCE TIMEFRAME

See also a more complex funnel query example.

Funnel queries require the funnel function, an attribute to funnel, and at least two steps:

  1. The first step is the anchor step, which will always represent 100% of the results.
  2. The second and later steps describe the number of users who have also completed additional actions. This number typically will be less than 100%. However, it could be 100% if every user who completes action (A) also completes the additional actions being queried.

Funnel query technical details

One way to use funnel queries is to calculate the rate at which multi-step, ordered sequences were completed over a given timeframe, like in the New Relic One signup example. But you can also use funnels to calculate overlap between several distinct actions that don't have a sequential relationship to one another. In other words, the order of steps doesn't impact the calculations performed.

The way funnel queries compute results varies depending on the size of the data set:

  • If the funnel is dealing with 256 funnel attribute values or fewer, it will calculate the value exactly.
  • If it's dealing with more than 256 funnel attribute values, it applies an algorithm called MinHash to calculate approximate results for optimized performance.

This means that for large data sets, there may be occasional "false positives" at the level of individual data points. These do not interfere greatly with the accuracy of the numerical estimates provided in query results.

Here's a detailed breakdown of technical details and constraints for funnel queries.

Technical details Comments
Order of steps The order of steps completed is not enforced and does not impact results.
Attributes You can only run funnel queries on one attribute at a time.
Unique values For funnel queries that involve more than 256 unique funnel attribute values, the results are approximate.
Maximum steps You can have a maximum of 10 steps within a single funnel query.

For more information, check out the New Relic University tutorial Funnel queries. Or, go directly to the full online course Writing NRQL queries.

Funnel query example

This example queries the New Relic Browser PageView event and its attributes. It queries unique browser sessions that have progressed from registration to account upgrades. Labels are included for each step, indicated by the keyword AS.

FROM PageView SELECT funnel(session, 
    WHERE pageUrl='http://www.storefront.com/signup' AS 'Email Sign Up', 
    WHERE pageUrl='http://www.appproduction.com/basic_feature' AS 'Feature Compare', 
    WHERE pageUrl='http://www.appproduction.com/advanced_feature/upgrade' AS 'Upgraded Account') 
    SINCE 12 hours ago

This query returns the following:

Screenshot of funnel function
An example NRQL funnel query that displays a count of the users who registered for an account, visited a feature-compare page, and upgraded.

Include additional actions inside the parentheses of the funnel function in a comma separated list:

SELECT funnel(session, 
    WHERE name='Controller/about/main' AS 'Action A', 
    WHERE name = 'Controller/about/careers' AS 'Action B', 
    WHERE name = 'Controller/about/insights' AS 'Action C', 
    WHERE name = 'Controller/about/apply' AS 'Action D') 
    FROM PageView 
    SINCE 1 week ago

For more help

Recommendations for learning more: