Context

Discover the variables you can use in your queries.

In CQL, the term context refers to the data your queries can use to gain insight into the user's environment. This includes information like the user's geographic location or the page they are currently viewing.

The data available for your queries depends on the channel through which your users interact with your application. For example, websites have pages, while mobile applications have screens.

To access the information available in the context, you use variables. For example, the page variable gives you information about the current page, while the location variable tells you the current geographic location.

The table below lists the currently available variables and what they provide:

VariableTypeDescription
nowDate-timeThe current date and time.
yesterdayDateYesterday's date.
todayDateToday's date.
tomorrowDateTomorrow's date.
userUserThe user currently using the application.
sessionSessionThe user's current session or visit.
deviceDeviceThe user's device.
locationLocationThe user's geographic location.
cartCartThe contents of the user's shopping cart.
campaignCampaignThe last campaign the user interacted with.
contextContextThe evaluation's context.
pagePageThe webpage currently viewed by the user.
browserBrowserThe user's web browser.

Variables

The following sections present a categorized list of variables you can use in your queries, sometimes accompanied by informative icons.

These icons indicate the availability and usage restrictions of the information. For example, it may be available only to identified users or during web sessions.

Here is what each indicator means:

  • Integration required: Information that is not automatically collected by our SDKs and must be sent by your application to be available for your queries.
  • Available for web sessions only: Channel-specific information that is only available for web sessions, such as the current page or browser.
  • Available for identified users only: As part of our commitment to privacy, we prevent access to personally identifiable information of unidentified users to promote respect for the right to erasure.

Evaluation

Evaluation variables are specific values associated with each evaluation, including the date, time, and context in which the evaluation occurs.

For example, the context variable might provide information about an upgrade opportunity, such as the name of the feature and the number of members in the user's organization. These details can give you insight into the user's environment and help you decide the best offer to present.

This is a list of the evaluation variables you can use in your queries:

ExpressionExample
now2024-05-05T01:00:00
yesterday2024-05-04
today2024-05-05
tomorrow2024-05-06
context["timeZone": ...]
context's timeZone"America/Sao_Paulo"
context's /*<custom-attribute>*/
"some value"

User

User variables provide information about the person currently using the application, such as their name, email address, and age.

The following table lists the variables and properties you can use to access information about the user:

ExpressionExample
user["name": "John Doe", ...]
user's name
"John Doe"
user's firstName
"John"
user's lastName
"Doe"
user's age
30
user's birthDate2000-08-31
user's gender
"male"
user's email
"john.doe@email.com"
user's alternateEmail
"john.doe@work.com"
user's phone
"+1 987 654 321"
user's alternatePhone
"+1 123 456 789"
user's address
["street": ...]
property street of user's address
"Main St"
property city of user's address
"New York"
property state of user's address
"NY"
property country of user's address
"US"
property postalCode of user's address
"10001"
user's avatar
https://ex.com/john.png
user's company
"Croct Inc."
user's companyUrl
https://croct.com
user's jobTitle
"Software Engineer"
user's interests
["react", ...]
user's activities
["signed-up", ...]
user's stats["pageviews": 1, ...]
property sessions of user's stats1
property orders of user's stats2
user's /*<custom-attribute>*/
"some value"

Session

Session variables provide information about the current visitor session, such as how long the user has been active or custom attributes that your application may have set.

The following table lists the variables and properties that you can use to access information about the current session:

ExpressionExample
session["start": ...]
session's start2024-05-05T12:00:00
session's end2024-05-05T12:01:40
session's durationPT1M40S
session's landingPage
https://croct.com/demo
session's referrer
https://google.com
session's stats["pageviews": 1, ...]
property pageviews of session's stats
1
property tabviews of session's stats
2
property orders of session's stats3
session's /*<custom-attribute>*/
"some value"

Navigation variables provide information about the journey that the user has taken through your application, such as the current page or screen that the user is viewing.

The following table lists the variables and properties that you can use to access information about the user's navigation:

ExpressionExample
page
["title": "Croct - Docs", ...]
page's title
"Croct - Docs"
page's url
https://croct.io/docs?lang=en#js
page's path
"/docs"
page's query
["lang": "en"]
property lang of page's query
"en"
page's anchor
"js"
page's referrer
https://google.com

Technology

Technology variables provide information about the technologies the user is using to access your application, such as their browser or device.

The following table lists the variables and properties that you can use to access information about the user's technology:

ExpressionExample
browser
["name": "Chrome", ...]
browser's name
"Chrome"
browser's version
"80.0.2"
browser's type
"web"
device["name": "Mac", ...]
device's name"Mac"
device's vendor"Apple"
device's os["name": "macOS", ...]
device's category"desktop"
property name of device's os"macOS"
property version of device's os"10.15.1"

Location

Location variables provide information about the geographic location from which the user is accessing your application, such as the user's country or city.

The following table lists the variables and properties that you can use to access information about the user's location:

ExpressionExample
location["continent": "North America", ...]
location's continent"North America"
location's continentCode"na"
location's country"United States"
location's countryCode"us"
location's region"California"
location's regionCode"ca"
location's state"California"
location's stateCode"ca"
location's city"Mountain View"
location's district"Santa Clara County"
location's timeZone"America/Los_Angeles"

Marketing

Marketing variables provide information about the marketing campaigns that the user has engaged with, such as the name of the campaign or where the user came from.

The following table lists the variables and properties that you can use to access information about marketing campaigns:

ExpressionExample
campaign["name": "personalization", ...]
campaign's name"personalization"
campaign's source"google"
campaign's medium"paid"
campaign's content"main-banner"
campaign's term"personalized landing page"

Shopping

Shopping variables provide information about the buying behavior of the user, such as the stage of the purchase process or the items in the user's cart.

The following table lists the variables and properties that you can use to access information about shopping behavior:

ExpressionExample
cart
["total": 599.00, ...]
cart's stage
"checkout"
cart's items
[[...], [...], ...]
property index of cart.item[1st]
0
property id of cart.item[1st]
"12345"
property name of cart.item[1st]
"iPhone"
property sku of cart.item[1st]
"IP-512GB-BLACK"
property category of cart.item[1st]
"Electronics"
property brand of cart.item[1st]
"Apple"
property variant of cart.item[1st]
"512GB Black"
property displayPrice of cart.item[1st]
"599.00"
property originalPrice of cart.item[1st]
"699.00"
property url of cart.item[1st]
https://ex.com
property image of cart.item[1st]
https://ex.com/iphone.png
property quantity of cart.item[1st]
1
property coupon of cart.item[1st]
"10OFF"
property discount of cart.item[1st]
100.00
property total of cart.item[1st]
599.00
cart's currency
"usd"
cart's shippingPrice
9.99
cart's coupon
"FREE-SHIPPING"
cart's discount
9.99
cart's costs
["shipping": 9.99, ...]
cart's taxes
["tax": 0.00, ...]
cart's subtotal
609.98
cart's total
599.00
cart's lastUpdate
2024-05-05T13:01