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 Sailthru’s 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 Sailthru-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}.

Interest-Based Content Recommendations from a Feed

Use Case: You collecting 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.

Top