Developer Mode - IQL Reference
This section details the Infinity Query Language (IQL) syntax available for Developer Mode within Actions.
In this topic:
Clauses
Tip: See Using Developer Mode within Actions - Clauses for guidance on clauses.
ON TRIGGER()
Desciption
ON TRIGGER()
defines whether a session should qualify for an Action to be triggered. For example, the following trigger will execute the action when a the session is closed if a user has performed a View Product behavior within the session (see Behaviors for Behavior definitions):
Example Syntax
Sample IQL Query
Sample Explained
Triggers once the session has closed if a user has performed a View Product behavior within a session. It will emit the SKUs of all products which have been viewed:
Product SKU |
---|
["SKU13245","SKU234324"]
|
Note: What's the difference between WHERE
and ON TRIGGER()
?
Broadly speaking, you should use ON TRIGGER()
to decide what behaviors should qualify a session for the action to trigger and then WHERE
to further refine whether the action should trigger. Please see the Frequently Asked Questions for the difference between WHERE
and ON TRIGGER()
and advice on when you should use each. Additionally, you can view some Example Queries.
Tip: Working with open sessions
Please note that once the ON TRIGGER()
conditions are met - the session will be in a qualified state. From that point on, all further events within the session will trigger your action. To ensure that actions are only triggered for the specific events you want - you should use a WHERE
clause to define when the action should trigger.
This is particularly important if you are triggering actions for an open session (using NOT behavior.[Close session]
). For closed sessions (behavior.[Close session]
), this doesn't really matter as this is the final event within the session.
Please see Using WHERE
to work with Open Sessions for further details.
SELECT
Desciption
Define what data you would like to select and pass on to your desired destination:
Tip: You can use Aliases to give your selections user-friendly names.
Sample IQL Query
Sample Explained
Selects the Page URL parameter and data.wt.my_parameter parameter for the matching result. For example:
My Page URL | data.wt.my_parameter |
---|---|
https://www.mywebsite.com/example_page | Example value for my parameter |
WHERE
Desciption
Apply additional criteria for when your action should trigger:
Sample IQL Query
Sample Explained
Triggers when the user views a page with a Page Title containing 'my cart' (and selects the Page Title and Product SKU of the matching result) but only when the Product SKU parameter is available.
Page Title | Product SKU |
---|---|
My E-commerce Site | My Cart | SKU14234
|
Tip: Working with open sessions
Please note that with once the ON TRIGGER()
conditions are met - the session will be in a qualified state. From that point on, all further events within the session will trigger your action. To ensure that actions are only triggered for the specific events you want - you should use a WHERE
clause to define when the action should trigger.
This is particularly important if you are triggering actions for an open session (using NOT behavior.[Close session]
). For closed sessions (behavior.[Close session]
), this doesn't really matter as this is the final event within the session.
Please see Using WHERE
to work with Open Sessions for further details.
Operators
Here is a list of available operators:
AND
Desciption
Standard AND
boolean operator:
Sample IQL Query
OR
Desciption
Standard OR
boolean operator:
Sample IQL Query
= (equals)
Desciption
Equals:
Sample IQL Query
<> | != (not equal)
Desciption
Not equal to:
Sample IQL Query
LIKE (contains, starts with and ends with)
Desciption
Can be used for contains (by enclosing value with %), starts with (end with %) or ends with (start with %):
Sample IQL Query
NOT
Desciption
Can be used to inverse the proceeding operator:
Sample IQL Query
> (greater than)
Desciption
Greater than (must be used on numeric values):
Sample IQL Query
< (less than)
Desciption
Less than (must be used on numeric values):
Sample IQL Query
>= (greater than or equal to)
Desciption
Greater than or equal to (must be used on numeric values):
Sample IQL Query
<= (less than or equal to)
Desciption
Less than or equal to (must be used on numeric values):
Sample IQL Query
Exists()
Desciption
Used to determine if something exists:
Sample IQL Query
Selectors
Last()
Desciption
Select the parameter value for the most recent event within a session (may or may not be populated depending on the event):
Sample IQL Query
Latest()
Desciption
Select the last known value for the parameter within a session:
Sample IQL Query
First()
Desciption
Select the parameter value for the first recent event within a session (may or may not be populated depending on the event):
Sample IQL Query
Earliest()
Desciption
Select the first known value for the parameter within a session:
Sample IQL Query
Session()
Desciption
Allows you to specify an entire session (and select events from within the session):
Sample IQL Query using WHERE
First Sample Explained
Specifies the condition that at least one of the events within the session saw a parameter.[Transaction Event]
of p
(that is, a purchase event).
Tip: This is the equivalent of the legacy Streams syntax of ANY(data.wt.tx_e = 'p')
. See Legacy Stream Syntax (including HAVING).
Sample IQL Query using WHERE
Second Sample Explained
Specifies the condition that none of the events within the session saw a parameter.[Transaction Event]
of p
(that is, the visitor did not complete a purchase event).
Tip: This is the equivalent of the legacy Streams syntax of ALL(data.wt.tx_e != 'p')
. See Legacy Stream Syntax (including HAVING).
Sample IQL Query using SELECT
Third Sample Output
["My Cart","View Cart"]
Third Sample Explained
Returns all values which contain cart for parameter.[Page Title]
within a session in chronological order of when they were seen.
Filter()
Desciption
Allows you to further refine selections:
Sample IQL Query
Sample Output
["SKU1","SKU2"]
Sample Explained
The above example selects the last seen value of Product SKU but only when the Product SKU was seen at in the same event where the Page URL equals 'my.website.com/cart'.
toString()
Desciption
Allows you to convert your selection to a string and concatenate them with your own delimiter using the syntax tostring(PARAMETER,DELIMITER)
:
Sample IQL Query
Sample Output
homepage,product_index_page,search_page
Sample Explained
The above example selects all the values of parameter.[Page Title]
seen during a session and concatenates them with a ,
.
Tip: This is the equivalent of the legacy Streams syntax of CONCAT(data.wt.ti,',')
. See Legacy Stream Syntax (including HAVING).
Distinct()
Desciption
Filters selection to a unique list:
Sample IQL Query
Sample Output
["Homepage","Product Page"]
Sample Explained
The above example selects all the unique values of parameter.[Page URL]
seen during a session and concatenates them with a ,
.
Tip: This is the equivalent of the legacy Streams syntax of CONCAT_DISTINCT(data.wt.ti
.
You can also choose convert this to a string a specify your own delimiter by using the following syntax: tostring(distinct(session(data.wt.ti)),';')
.
See Legacy Stream Syntax (including HAVING).
Other Syntax and Concepts
Aliases
You may wish to use Aliases to expose your selected parameters as more usable names in your Actions Mappings. For example, the following query would allow you to select myproductsku as the parameter name:
Sample Developer Mode SELECT
Referring to Parameters and Behaviors Attributes
Tip: See Sessions for example of how selection parameters can be affected by sessions.
You can refer to behaviors and parameters in IQL using the following syntax:
Referring to Raw Parameters
You can refer to the raw incoming parameter (for example, wt.ti
- Page Title) as data.wt.ti
in IQL:
Sample IQL
Referring to Named Parameters
You can refer to a parameter available in the Actions user interface (either default parameters or user-added parameters) as see parameter.[PARAMETER NAME]
:
Referring to raw parameters
Sample IQL
Referring to Behaviors Parameters
You can refer to attributes stored within a behavior as see behavior.[BEHAVIOR NAME].[ATTRIBUTE]
:
Referring to Behavioral Attributes
Sample IQL
Sessions
Behavioral data is session-based by default within Actions. Therefore, when writing queries it is important to understand that actions evaluate incoming events which are tied together in the form of a session. This is typically handled by using the behavior.[Close session]
behavior within your ON TRIGGER()
clause. For example:
Example Query using the Session Behavior - Open Session
Sample IQL
The above query will:
-
Trigger
:-
as a user adds an item to their cart session
-
AND
the session is not closed (this means the action will trigger immediately).
-
-
Select
:-
All SKUs added to the user's cart during the session (including the current one).
-
The
latest
Page Title seen by the user (without thelatest
function, you would only see a value for Page Title if it were present in the same event as the add to cart event)
-
Working with Closed Sessions
If you wish to trigger actions when the user's session has closed (for example, if you want to ensure a user did not purchased something during a session) then you can use the standard behavior.[Close session]
syntax as follows:
Example Query using the Session Behavior - Closed Session
Sample IQL
The above query will:
-
Trigger
when:-
the session closes
-
AND
they add product to their cart -
AND
they have not purchased a product during their session.
-
-
Select
:-
All SKUs added to the user's cart during the session (including the current one).
-
The
latest
Page Title seen by the user (without thelatest
function, you would typically not see the page title you expect - see Session Close Event)
-
Session Close Event
When a session closes (typically defined as 30 minutes after the last event was received from an active user), a new event is fired which contains session.closed=true
which triggers behavior.[Close session]
. This event will re-fire the same parameters seen in the last event during the session. For example:
Last Event during Session
Parameter | Value | Notes |
---|---|---|
session.closed
|
false | This denotes that the session has not closed |
data.wt.ti
|
Sharp Santoku Knife | This is the Page Title parameter |
data.wt.page_type
|
Product Page | - |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
Session Close Event
Parameter | Value | Notes |
---|---|---|
session.closed
|
true | This denotes that the session has closed |
data.wt.ti
|
Sharp Santoku Knife | This is the Page Title parameter |
data.wt.page_type
|
Product Page | - |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
This means that if you refer to parameters directly (for example, parameter.[Page Title]) without a selector like latest()
or first()
(for example, latest(parameter.[Page Title])
) then you will refer to the parameter available within the event which triggered the action.
Example
The following example demonstrates how the the selections will be processed when an action is triggered on a session close event:
Example Query
Sample IQL
The above query will:
-
Trigger
when:-
the session closes
-
AND
the user has added an item to their cart within the session -
AND
has not purchased a product within the session.
-
-
Select
:-
The Product SKUs of all of the items added to the user's cart
-
The Page Title available in the session close event (selected as 'Current Page Title')
-
The
latest
Page Title available in the session close event (selected as 'Latest Page Title')
-
The following events demonstrate what the above query would return in an example session:
Event 1 - Homepage Visit
Parameter | Value | Notes |
---|---|---|
session.closed
|
"false" | This denotes that the session has not closed |
data.wt.ti
|
"Homepage" | This is the Page Title parameter |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
Event 2 - Product Page Visit
Parameter | Value | Notes |
---|---|---|
session.closed
|
false | This denotes that the session has not closed |
data.wt.ti
|
Sharp Santoku Knife | This is the Page Title parameter |
data.wt.page_type
|
Product Page | - |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
Event 3 - Add to Cart (last event during session)
Parameter | Value | Notes |
---|---|---|
session.closed
|
false | This denotes that the session has not closed |
data.wt.tx_e
|
a | Transaction Event - this denotes that a product has been added to the cart |
data.wt.pn_sku
|
SKU-SH324 | This is the Product SKU of the added product |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
Event 4- Session Close Event
Parameter | Value | Notes |
---|---|---|
session.closed
|
true | This denotes that the session has closed |
data.wt.tx_e
|
a | Transaction Event - this denotes that a product has been added to the cart |
data.wt.pn_sku
|
SKU-SH324 | This is the Product SKU of the added product |
...other parameters... | ... | This not an exhaustive list of parameters available within the event |
Note: The final session close event triggers 30 minutes after event 3 - the last event during the session.
Action Selections
When the action triggers, the following data will be selected:
Selection | Value | Notes |
---|---|---|
behavior.[Add product to cart].[Product SKU]
|
["SKU-SH324"] | Only one item has been added to the cart so a single item is listed |
parameter.[Page Title] AS 'Current Page Title'
|
- | This is blank (as it was not present in the final event within the session close event) |
Latest(parameter.[Page Title]) AS 'Latest Page Title'
|
Sharp Santoku Knife | The latest seen value of Page Title |
The above selection illustrates that Current Page Title has not value because the Page Title (data.wt.ti
) was not present in the final event of the session (and therefore it was unavailable when the action ran - within the session close event). Also, the Latest Page Title returns Sharp Santoku Knife as the latest()
ensures that only the last seen value is returned.
Frequently Asked Questions
Legacy Stream Syntax (including HAVING)
Some of the syntax previously available in the legacy Streams syntax is now unavailable and unnecessary due to the simplicity and power of using IQL for queries. For example, HAVING
is no longer necessary as the same results can be achieved using a combination of ON TRIGGER()
, WHERE
and SELECT
clauses.
However, here are some useful IQL equivalents to legacy Streams syntax:
Any()
Returns true if any event within the session meets your criteria:
What? | Syntax | Example |
---|---|---|
Legacy Streams Syntax | ANY(ARG)
|
ANY(data.wt.tx_e='p')
|
IQL Syntax | session(ARG)
|
session(data.wt.tx_e='p')
|
All()
Returns true if all event within the session meets your criteria:
What? | Syntax | Example |
---|---|---|
Legacy Streams Syntax | ALL(ARG)
|
ALL(data.wt.tx_e!='p')
|
IQL Syntax | not session(not((ARG))
|
not session(not((data.wt.tx_e!='p'))
|
CONCAT()
Returns all values for a given selection parameter (in chronological order) with your chosen delimiter:
What? | Syntax | Example |
---|---|---|
Legacy Streams Syntax | CONCAT(ARG,"DELIMITER")
|
CONCAT(data.wt.tx_e,";")
|
IQL Syntax | tostring(ARG,"DELIMITER")
|
tostring(session(data.wt.tx_e),";")
|
CONCAT_DISTINCT()
Returns all unique values for a given selection parameter with your chosen delimiter:
What? | Syntax | Example |
---|---|---|
Legacy Streams Syntax | CONCAT_DISTINCT(ARG,"DELIMITER")
|
CONCAT_DISTINCT(data.wt.tx_e,";")
|
IQL Syntax | tostring(distinct(ARG),"DELIMITER")
|
tostring(distinct(session(data.wt.tx_e)),';')
|