Client

Client

{{ client }}

The client object is available on every page, and contains information about the history of the browser used to access the site. Note that most of these properties are only meaningful if the user has allowed permission for sessions.

Additionally, client properties require cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) or without permission for session will always behave like an initial page-load without existing client information.

The client object is one of a handful of simple mechanisms to enable personalization on your site. Used well, these can be powerful tools for developers and website owners.

Name Type Description
is_valid Boolean Whether or not the user (or developer) has granted permission for a session
allowed Boolean Whether or not the user (or developer) has granted permission for a session
id String The unique identifier for the client browser. If the user does not have permission for a session this will be empty
user_agent String The user-agent string sent with the request. This is an alias of request.user_agent
permissions client_permissions The permissions that are set for the current client. The shortcut for this is {{ client_permissions }}
session session The current session for the client. The shortcut for this is simply {{ session }}
cookies cookies The cookies for the current client. This is an alias of {{ request.cookies }} and the shortcut for this is {{ cookies }}
first_request_date time The date that we received the first request from this client. Note that this is dependent on a number of outside factors, including the client's use (and/or clearing) of cookies and their allowance of sessions
num_requests Integer The total number of requests made by this client since the first_request_date
num_pages Integer The total number of successful page requests made by this client since the first_request_date
num_sessions Integer The total number of sessions created for this client since the first_request_date
properties list The full list of custom properties that are set for the current client. Note that this list only includes the keys, the values will have to be retrieved using the keys
max_properties Integer The maximum number of properties that may be stored on the client object. Adding new properties beyond that limit will result in the oldest properties being replaced by the newer properties. The default limit to the number of properties is currently 100. If you need more than 100 client properties contact Marketpath about raising your limit
* String Individual custom properties for the client may be accessed using {{ client.propertyName }} or {{ client['property-name'] }} syntax
output String JSON representation of the client object, similar to {{ client | inspect: 4, false }}

The client object is copyable, and when copied using the {% copy_to_dictionary %} method, the keys will be the custom property names and the values will be the corresponding custom property values.

The client object may also be enumerated as a list of strings, which will be the names of the custom properties saved on the client. Note that this list will only include the property names when the enumeration started and adding or removing client properties during enumeration will not affect the property names for the current enumeration.

{% set_client %}

Saves custom properties on the client that will survive across multiple sessions until they are changed, unset, or the "session" permission expires. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% unset_client %}

Removes custom properties from the client.

Examples

Set_client

Copy
{% if request.query_params.hide_popup_for_all_time %} {% set_client show_popup:"false" %} {% endif %}

Set_client multiple dynamic values

Copy
{% if submission.is_valid %} {% var forms_submitted = client.submittedForms | to_int | plus: 1 %} {% var client_formname = form.name.value | prepend: 'submitted' %} {% set_client submittedForms:forms_submitted lastKnownEmail:submission.email &client_formname:'true' %} {% endif %}

First client Session

Copy
{% if client.allowed and client.num_sessions == 1 %}

This is your first session {% if session.first_page %}AND your first page!{% endif %}

{% endif %}