Skip to main content
Parse URLs stored in your JSON properties into their component parts (host, path, port, query string, and more) so you can segment users by where they came from or where they went.

domain

Extracts the hostname from a URL. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The hostname as a string, or an empty string if the URL cannot be parsed.
Edge divergence: on ClickHouse domain() returns an empty string for URLs that contain userinfo (user:pass@host), whereas the PostgreSQL idiom extracts the host. Use URLs without userinfo for cross-backend parity.
Example
Group users by the host of their website

domainWithoutWWW

Returns the hostname of a URL with any leading www. removed. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The hostname without a leading www. as a string, or an empty string if the URL cannot be parsed.
Example
Normalize the referrer host across www and non-www

path

Returns the path of a URL, without the query string. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The path as a string (for example /docs/lists). Empty if the URL has no path.
Example
Count events by the page path that was visited

queryString

Returns the query string of a URL, without the leading ? and without any # fragment. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The query string as a string (for example utm_source=newsletter&plan=pro), without the leading ?. Empty if the URL has no query string.
Example
Inspect the tracking parameters on referrer URLs

protocol

Extracts the protocol (scheme) from a URL. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The protocol as a string (for example https, http, ftp, mailto). Empty if it cannot be determined.
Example
Segment users whose website is served over HTTPS

port

Returns the port of a URL. Syntax
Arguments
  • url — the URL to parse, as a string.
  • default_port — optional value returned when the URL has no port; defaults to 0.
Returned value
  • The port number as an integer, or default_port (or 0) when the URL contains no port or cannot be parsed.
Edge divergence: on ClickHouse port() returns 0 for URLs that contain userinfo (user:pass@host:port), whereas the PostgreSQL idiom extracts the port correctly. Use URLs without userinfo for cross-backend parity.
Example
Find users whose website URL specifies a non-standard port

topLevelDomain

Extracts the top-level domain (TLD) from a URL. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The top-level domain as a string (for example com, io), or an empty string if the URL cannot be parsed.
Example
Group users by the top-level domain of their website

fragment

Returns the fragment identifier of a URL (the part after #), without the leading hash. Syntax
Arguments
  • url — the URL to parse, as a string.
Returned value
  • The fragment as a string, without the leading #. Empty if the URL has no fragment.
Example
Find users whose landing URL points at a specific section