horizon_select
Description
Based on the interests of the current user, returns top items from an array of content or products.
list horizon_select( array input , integer quantity , optional string engine , optional object filter_tags )
Given an input array of JSON objects, returns an array of quantity of those objects that the user is determined to be most interested in by the Personalization Engine, sorted by level of interest (descending). The last two parameters, engine and filter_tags, are optional ways to further refine and filter the content that is returned, and are especially powerful when used in Site Personalization Manager sections. (See Optional Parameters, below.)
The objects in the input array can contain any number of properties, but they must contain the tags property, which must be a comma-separated string or array of strings listing the tags that are relevant to this piece of content. You also may use the weight property, which can be any number to weight the value of the piece of content. For example, if you are pulling headlines from your site you may want to give a higher weight to headlines with higher numbers of pageviews.
There are many handy uses for this function, but one of the most useful involves using a Data Feed as the source for your input array. For your data feed, you can choose to use a generated content feed.
For more information about using content feeds with this function, see Use Feeds and Other Content Data in Templates.
Example
{myfavoritefood = horizon_select ( [ {'tags': ['trixie'], 'name':'msd Fruit Snacks' }, {'tags': ['kong,trixie'], 'name':'Cran-Apple Fruit Snacks' }, {'tags': ['kong'], 'name':'Lemon Fruit Snacks'} ], 2) }
After the above function is run, your two favorite fruit snacks are available in Zephyr as {myfavoritefood[0].name} and {myfavoritefood[1].name}.
andfilter_tags
parameters to further refine the content displayed to a user. filter_tags
, which lets you require certain tags or exclude certain tags from returned content, is especially useful with Site Personalization Manager: based on the context in which the page is being viewed, you can dynamically pass in variables/tags on page load in order to affect the content that is displayed, even when that content is sourced from the same section and feed.
Parameter | Description | Format/Example |
| Specifies whether the system should treat your section as supporting |
|
| Allows you to filter thereturned content items by specifying one or more content tags to require or exclude from the returned recommendations content. This is an object containing:
|
Your You can use any variable names to send these values to the template,then include them in your filter_tags object. For example, if you sent your tags and your include value using the variablesmytags and myinclude :{filter_tags = { "tags" : mytags, "include" : myinclude} } {content = horizon_select( content, 6, commerce, filter_tags)} |
Interest-Based Content Recommendations from a Feed
Use Case: You collect robust interest data on your users using on-site sailthru.tags, and you want to use your spidered content to recommend the top three pieces of content from a data feed. Using horizon_select, you can pick content based on user interest data. Note: personalize() has parity with horizon_select() but with additional functionality.
Zephyr:{personalizedContent = horizon_select(content, 3)} Here are your top ten stories for the day! {foreach personalizedContent as c} <a href="{c.url}">{c.title}</a> <br/> {/foreach}
Output:
Here are your top three stories for the day!
Spider-Man: Threat or Menace?
Get Your First Look at the New iPhone at the Times Square Apple Store
From the Fashion Blog: The Most Comfortable Socks You’ll Ever Own
Explanation: This script uses the horizon_select() function, which finds the top three pieces of content from a data feed to users based on on-site user interest tags. Each user’s top three stories get added to an assignment called “personalizedContent”, which is then looped through in the template, displaying each title and URL in order of interest. Note: personalize() has parity with horizon_select() but with additional functionality.