Skip to main content
Skip table of contents

Look-Ups

Lookups in applications are used to represent a set of codes and their translated meanings. Let’s have a look at the available lookup tags within ZML:

Resource Look-Ups

To add details from specific resources to your content instead of relying on recommendations, you can use the resource look-up merge tags. Resources can be retrieved with either a single resource lookup or by querying for multiple resources.

Specific Resource Lookup

Individual resources can be retrieved with any property a resource has. The most common and consistent way to retrieve a specific resource is by using the resource ID. In the following example, the resource ID is the same as the product SKU.

{% resource product | id: sku %}

This tag creates the object {{product}}and assigns the contents of the resource object to it.

If you want to populate the title of the resource in the content, use {{product.title}}.

Multiple Resource Query

Retrieving multiple resources without the personalization help of our Recommendations engine is done with a resources query. Here is an example of a 'resources' tag:

{% resources products
| count: 3
| filter: 'resource-type', '=', 'article|product'
| filter: 'pubDate', 'AFTER', '-P1D'
| filter: 'category', 'CONTAINS', 'baseball'
| sort_field: 'start_date'
| sort_order: 'asc'
%}

Resources Query Parameters

Parameters

Description

count

Specify the number of resources to be returned in your query.

filter

The one or more resource fields to query against.

sort_field

The numerical, timestamp, or string type fields to sort the returned array on.

sort_order

The order in which the array of resources will be returned.

Points to Remember

{% resources my_product

count: 3

filter: 'resource-type', 'CONTAINS', 'product'

sort_order: 'desc'

%}

  • Operator names should be in uppercase. In this example, use ‘CONTAINS’ instead of ‘contains’

  • variable names should be unique and differentiated across other variables and values within the tag. In this example, since ‘product’ is used as a value, do not use that as a variable name elsewhere.

  • variable names should not conflict with property names that may be available on the profile.

Resources

Resources, also known as feeds/catalogs, are product listings of a client’s domain like e-commerce, arts, banking, and more. This list is synced to ZMP daily.

Variants

Variants are sub-products or child nodes of the same product.

Default Product

Variant Product: (Blue Highlight)

ZMP will result in only very few products in the resources' graphical UI. So, to identify and analyze all the data available in resources, we are using the below liquid syntax as a solution:

Results in Resources UI

Resource Lookup Syntax

{% resource product | id: "9097" %}

<br>product=>{{product}}}<be>

Resource with Variant Lookup Syntax

{% resource product | id: "9097" %}

{% assign get_v_p = product["variants"]["100083508"] %}

<br>Variant=>{{get_v_p}}<br>

Event Look-Ups

Trigger Event Object

For content being sent from a trigger campaign, an event object is available to populate information in content from the event that triggered the campaign. The properties available in the event are the same properties passed in the payload of the event. Take the following purchased event as an example:

Purchased Event Payload

{

"session": "afb35e24-37a9-40b4-96e5-7eb937c064e5",

"last_purchase":

{ "items": [

{

"productsku": "J9834RHJ",

"productname": "Some Cool Pants",

"quantity": 1,

"price": 45.68

}

],

"total": 45.68,

"cartuserdata": {

"first_name": "Ryan",

"last_name": "Malone",

"email": "rmalone@zetaglobal.com"

}

}

}

To populate the productname information from the first item in this purchased event, we can use the following event object:

Input

You bought: {{ event.purchased.last_purchased.items[0].productname }}

Output

You bought: Some Cool Pants

Event Look-Up Tag

Multiple past events can also be used in content using an event look-up tag.

The following example creates a variable called purchases as an array of the last three purchase events for the given user_id the message is being created for. The full contents of the array can be viewed in content using {{purchases}}, or use a for loop to iterate over the array to find the details you need.

Input

{% event purchases | event_type: 'purchase' | count: 3 %}

The event_type parameter can be changed to retrieve events of the specified name. The count parameter sets the limit for the number of past events that should be retrieved.


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.