Web types

Learn about the web-related types available in CQL.

Web types refer to general web-related concepts such as URLs, pages, and the context of a user in a web application.

This summary provides an overview of the web-related types:

TypeDescription
URIA web address, like a URL.
PageA webpage visited by a user.
Web contextThe context of a user in a web application.

URI

This type denotes the location of a resource, like a webpage or an image, as defined by the RFC 3986 standard.

People sometimes use URI and URL interchangeably, but a URL is a more specific type of URI that is widely used on the web.

A URI has several components, such as the hostname, path, and query string, which you can access through the properties listed below.

Properties

These are the available properties:

basestring

The base of the URI. The base refers to the portion preceding the path and consists of the scheme, hostname, and port.

Here are some examples:

URIBase
https://example.com/"https://example.com"
https://example.com/path?query#anchor"https://example.com"
https://example.com:8080/path?query"https://example.com:8080"
pathstring

The path component of the URI. The path is the part that comes after the hostname and port, and before the query string.

It is normalized to always start with a slash (/), with any additional trailing slashes removed.

Here are some examples:

URIPath
https://example.com/"/"
https://example.com/path/?query#anchor"/path"
https://example.com:8080/path?query"/path"
https://example.com:8080/path/?query"/path"
querymap<string,string>

The query string component of the URI parsed as a map, where the keys are the parameter names and the values are the parameter values.

The query string is the part that comes after the path and starts with a question mark, and consists of key-value pairs separated by ampersands.

Here are some examples:

URIQuery string
https://example.com/[]
https://example.com/path/?color=red["color": "red"]
https://example.com/?color=red&size=large["color": "red", "size": "large"]
https://example.com/?color[]=red&color[]=blue["color": ["red", "blue"]]
anchor(optional)string

The fragment component of the URI, also known as the anchor.

The fragment is the part that comes after the path and query string and starts with a hash.

Here are some examples:

URIAnchor
https://example.com/null
https://example.com/#hero"hero"
https://example.com/?color=red#colors"colors"

Page

This type represents a specific webpage visited by a user. It provides detailed information about the page, enabling personalized experiences based on user interactions.

It is important to note that, in certain situations, the information about a page may not be available. To account for this possibility, all properties of this type are optional.

Properties

These are the available properties:

title(optional)string

The title of the webpage. For example, "Croct Docs".

url(optional)URI

The URL of the webpage.

path(optional)string

The path component of the webpage URL.

This property is a shortcut for the URL path.

querymap<string,string>

The query string component of the webpage URL.

This property is a shortcut for the URL query.

anchor(optional)string

The fragment component of the webpage URL.

This property is a shortcut for the URL anchor.

referrer(optional)string

The URL of the webpage that linked to the current page, if any.

This property is a shortcut for the URL referrer.

Web context

This type represents the context of a user in a web application. It provides additional information about the user's environment that can be used in CQL queries.

Besides the predefined properties listed below, you can access any custom property defined in your application just like any other property. For example, if you have defined a custom property named channel, you can access it like this:

context's channel
Try in Playground

Properties

These are the available properties:

timeZone(optional)string

The time zone of the user's browser, as specified by the IANA time zone database.

<attribute>(optional)primitive|collection<primitive>

A custom attribute, where /*<attribute>*/ is the name of the attribute.