{{ 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.

Properties

string object_type
Will always be "client".
true/false is_valid
Whether or not the user (or developer) has granted permission for a session.
true/false allowed
Alias of is_valid.
string id
The unique identifier for the client browser. If the user does not have permission for a session this will be empty.
string user_agent
The user-agent string sent with the request. This is an alias of request.user_agent.
date first_request_date
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.
number num_requests
The total number of requests made by this client since the first_request_date.
number num_pages
The total number of successful page requests made by this client since the first_request_date.
number num_sessions
The total number of sessions created for this client since the first_request_date.
client_permissions 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 }}.
list properties
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.
number max_properties
The maximum number of properties that may be saved to the client.

Individual custom properties for the client may be accessed using {{ client.propertyName }} or {{ client['propertyName'] }} syntax.

You should be aware that you may only save a limited number of properties to the client object. Adding new properties beyond that limit will result in the oldest properties being "forgotten". 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.

You may also treat this object as a list containing all of the property names which may be iterated using a {% for %} loop. For more details, see the examples below:

Examples

{% if client.allowed and client.num_sessions == 1 %}
    <p>This is your first session {% if session.first_page %}AND your first page!{% endif %}</p>
{% endif %}
{% if client.allowed and client.num_sessions > 6 and client.VIP != "true" and client.first_request_date < request.date | add_years: -1 %}
    <p>You have viewed this site {{ client.num_sessions }} since {{ client.first_request_date | date: 'MMMM yyyy' }}. During that time you have looked at {{ client.num_pages }} pages. We are happy that you have taken so much interest in us, and would like to invite you to <a href="#"> join our VIP club</a>!</p>
{% endif %}

List all custom properties for the current client:

<h4>Client Properties:</h4>
<ul>
{% for property in client %} --equivalent to {% for property in client.properties %}
    <li><strong>{{property}}</strong> = {{ client[property] }}</li>
{% endfor %}
</ul>

Working with specific custom properties

{% if client.is_valid %}
    {% if client.custom_property_name %}
        <p>Custom Property: {{client.custom_property_name}}</p>
    {% endif %}
    {% if client['custom_property_name_2'] %}
        <p>Custom Property 2: {{client['custom_property_name_2']}}</p>
    {% endif %}
{% endif %}

Developer Overview

Liquid Markup