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.
You can use funnel
functions to 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:
- Visited the New Relic marketing page.
- Signed up for an account.
- 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
Funnel queries require the funnel
function, an attribute to funnel, and at least two steps:
- Begin with the anchor step, which always represents 100% of the results.
- Continue with an additional step or steps that describe the number of users who have also completed additional actions, typically than the 100% from the anchor step. However, it could be 100% if every user who completes action (A) also completes the additional actions you're querying.
Funnel query technical details
You can use funnel queries to calculate the completion rate for multi-step, ordered sequences over a given timeframe, like in the New Relic signup example. 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 won't impact the calculations.
The way funnel queries compute results varies depending on the size of the data set:
- If the funnel is processing with fewer than 256 funnel attribute values, it will calculate the value exactly.
- If the funnel deals with 256 or more 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 don't interfere 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 256 or more unique funnel attribute values, the results are approximate. |
Maximum steps | You can have a maximum of 10 steps within a single funnel query. |
Funnel example
This example queries the PageView
event and its attributes. It queries unique browser sessions from your users that have progressed from browsing for products, to adding them to their cart, to checking out. It includes labels for each step, indicated by the keyword AS
.
FROM PageView SELECT funnel(session, WHERE pageUrl LIKE '%browse%' as 'Browse', WHERE pageUrl LIKE '%cart%' as 'Cart', WHERE pageUrl LIKE '%checkout%' as 'Checkout') SINCE 1 week AGO
This query returns the following:
An example NRQL funnel query that displays a count of the users who browsed for products, added them to their cart, and then started to checkout.
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