Use Advanced Dynamic Message Content
You can use ADMC in the message content of your Mobile Data Campaigns and while creating Open-Time Email Campaigns and item templates. With ADMC, you can:
- Access the current product, article, blog, or category a visitor is currently viewing
- Access products in a visitor's cart
- Access multiple items by ID
- Specify the minimum and maximum number of items to be returned in campaigns
- Access items that visitors have viewed, sorted by recency, and not restricted to their current visit
- Match the least viewed or purchased items globally
- Sort matching items by name, price, or other fields to present the most relevant items to the campaign audience
- Match items based on a statistic from a lookback period other than the default one week
- Match only items that meet certain conditions, such as those with image URLs or containing specific keywords like "clearance"
To access the item (Product, Article, or Blog) the visitor is currently viewing, use the
$page.item variable. To access the category the visitor is currently viewing (or the category of the Item currently being viewed), use the
$page.category variable. The
$page.category variable can either be used directly within the message content or passed to a global or user query using
$itemOptions.withCategory($page.category.id). You can also use
$page.gender to include the brand and gender. If there’s more than one applicable category, brand, or gender, Personalization shows the first one found on the page (based on how the page is coded).
For more information, see Item Options.
To show data about the current items contained in the visitor's shopping cart, use
Or to show only the list of unique products in the visitor's cart, use
A single, specific item can be promoted using the Static subtab of the Promoted Content tab, but to promote more than one specific Item, use the
$tools.global.products.findById function as shown in the following example.
You can replace
brands, or other groupings configured in your Personalization Catalog, to show items in those groupings. For example, to show brands, use
$tools.global.brands.findById. To show multiple items, use
$tools.global.products.findByIds, which works similarly and accepts a list of up to 10 IDs. This function returns all items found in order by ID. Items that aren’t found are skipped.
For options that can be passed to the “viewed” function to specify minimum and maximum results, sorting, filtering, and other options, see Item Options.
To show items the visitor has recently viewed, with last viewed item first, the
$tools.user.products.viewed function can be used. You can access additional item types by replacing
brands, or other groupings configured in your Personalization Catalog. The lookback time period can’t be adjusted and is always this visit.
For options that can be passed to the
purchaseCount functions to specify minimum and maximum results, sorting, filtering, lookback time period, and other options, see Item Options.
To show items that the visitor has viewed the most times, use the
To show items that the visitor has spent the most time viewing, use the
$tools.user.products.viewTime function. Additional item types can be shown by replacing “products” with “categories”, “brands”, or other groupings configured in your Personalization Catalog. For example,
To show items that the visitor has purchased the most times, use the
To access Items that have been viewed the most times globally, use the
To access Items that visitors have spent the most time viewing globally, use the
$tools.global.products.viewTime function. Additional item types can be shown by replacing “products” with “categories”, “brands”, or other groupings configured in your Personalization Catalog. For example,
To access Items purchased the most times globally, use the
For options that can be passed to the
publishedDate function to specify minimum and maximum results, sorting, filtering, lookback time period, and other options, see Item Options.
To find items were recently published, sorted by published date, use the
$tools.(user|global).products.(viewed|viewCount|viewTime|purchaseCount) query functions can all be passed a set of item options to refine the results. Item options can specify minimum and maximum results, lookback time period, filtering, sorting, and so on.
Item options are created by calling multiple functions on the
$itemOptions object. For example, to create a set of item options that shows the top three items people spent the most time viewing today, sorted by product name, you could use:
By default, a message containing advanced dynamic queries renders only if there is at least 1 result, and a maximum of 5 results are returned. You can increase the minimum using
$itemOptions.minItems(n) and the maximum using
$itemOptions.maxItems(n). You can’t increase the maximum beyond 10.
For example, to render the message only if there are at least 3 results and to limit the number of results shown to 3, use:
By default, queries consider item data from the past week. To use a different lookback period, use the
$itemOptions.time function. For example, to consider today only, use:
The following functions are provided by the
$time singleton object:
thisWeek- current calendar week (with Monday as first day of week)
thisMonth- current calendar month
since(date)- since the specified date; date format is
lastNDays(n)- last n days, including today;
lastNDays(1)would mean today and yesterday
allTime- don’t define a specific date range
To filter results to contain products with a particular category, use
$itemOptions.withCategory(categoryId). For example, to filter by the category the visitor is viewing, use:
To filter by the visitor's most purchased category, use:
To filter results to contain only products with a specific brand, use
$itemOptions.withBrand(brandId). For example, to filter by visitor's most purchased brand, use:
To filter by gender:
Results can be filtered based on Item field values using any of the following conditions:
- Field has a value
- Field doesn’t have a value
- Field’s value contains a substring
- Field’s value doesn’t contain a substring
To only include Items that have image URLs, use:
To only include Items that have “clearance” in their descriptions, use:
The following functions are available, each corresponding to a different field:
The preceding functions correspond to the four types of conditions:
doesNotContain are case-insensitive.
By default, query results are returned in descending order with the most popular or most recently viewed Items listed first. To reverse the order, and return the least popular or least recently viewed Items first, use:
To sort the results for display, use the
$itemOptions.displaySort function. Use
$productSort for products,
$articleSort for articles, and
$blogSort for blogs. For example, to sort the results by product name, use:
The following functions are available on
$productSort, corresponding to different product fields:
The following functions are available on
$blogSort, corresponding to different article or blog fields:
By default, display sorting is done in ascending order. To use descending order instead, you can use the
By default, items the visitor is viewing are excluded from query results. To include them, use:
By default, Products that are currently in the visitor's cart are excluded from query results. To include them, use:
By default, items the visitor has viewed can be included in query results. To exclude any item the visitor has viewed, use:
By default, Products that the visitor has purchased can be included in query results. To exclude any product the visitor has purchased, use:
Typically, prices are the only numbers you need formatted. There are two options for how to format them.
The simpler option formats the price with the default dataset currency symbol using the default dataset locale:
If the default dataset currency is US dollars and the default dataset locale is US, the formatted currency would look like:
And for Euros with a French locale:
1 234,50 €
The other option is to format the number only using a fixed number of digits after the decimal point. Then, the currency symbol or word can be added as part of the message. For example:
Which would display as:
- Advanced Dynamic Message Content Cheatsheet
- Salesforce Help: Dynamic Message Content
- Salesforce Help: Open Time Email Campaigns