With the timeline event rollups feature, BlueConic enables you to query timeline events and store the results in profile properties for activation or export. Rollups include a Basic mode for configuring common, straightforward use cases and an SQL mode for more complex queries and advanced use cases.
This article provides information and examples of queries you would develop in SQL mode.
Using the SQL editor to write queries in AlaSQL
In SQL mode, the built-in SQL editor allows BlueConic developers to write SQL queries directly in AlaSQL (version 4.5.2). For more information, review the article Using SQL mode for timeline event rollups.
It is important to note that AlaSQL uses a slightly different syntax from traditional SQL. For instance, column names containing spaces are enclosed in backticks `
rather than double quotes ""
. For more details, review this AlaSQL page, which outlines the supported constructs.
Example queries
Request | Query | Stored | Comments |
All profiles that placed an order for a product with the tag 'Women' |
| Order tag | Order tag will be stored in the profile; tag ‘Women’ can be defined at the segment. |
All profiles of customers where the total order value for products with tag 'X' exceeded $500 |
| Total order value | The total order value will be stored in the profile; 500 can be defined at the segment. |
All profiles of customers where the average order value exceeded $100 |
| Average order value | The average order value will be stored in the profile; 100 can be defined at the segment. |
All profiles of customers where the total order value exceeded $1,000 |
| Total order value | The total order value will be stored in the profile; 1000 can be defined at the segment. |
All profiles that clicked an email in period X - Y |
| Number of emails clicked | Number of clicked emails will be stored in the profile; > 0 can be defined at the segment. |
All profiles that received an email in period X - Y and did not click an email in period X - Y |
| Number of emails delivered |
|
Number of products purchased in the profile lifetime |
| Number of unique products |
|
Number of products purchased in last A months |
| Number of products purchased in the last month |
|
Number of days between last 2 orders |
| Number of days |
|
Date of last purchase |
| Date of last order |
|
Top 3 tags that a customer bought products for |
| Tags and the number of products bought |
|
Joining multiple event types
In SQL mode, it is possible to join multiple event types, as long as there is a linking identifier. |
| Count of the number of orders that aren’t partially refunded | A sub-query is used so that an order that has multiple related refund events aren’t counted as duplicates. |
Like |
| Count of the number of iPhones ordered | The exact model (iPhone 14, iPhone 15, etc.) doesn’t matter. |
Top event |
| Name of the latest ordered product |
|
All profiles that ordered in last X days |
| Last order date | The last order date will be stored in the profile. Within the segment, use condition “within last X days.” |
All profiles that ordered a product with the tag 'X' in last Y days |
| Last order date | The last order date will be stored in the profile. Within the segment, use condition “within last X days.” |
All profiles that ordered Z products with tag 'X', but they did not buy products with tag 'Y' in the last 10 days. |
| Number of products ordered | Number of products ordered will be stored in the profile; Z can be defined at the segment. |
All profiles of customers that ordered at least twice in the last 1 year |
| Number of orders | The number of orders will be stored in the profile; "twice" can be defined at the segment. |
All product tags that someone ordered products for |
| All unique tags |
|