horizon_interest

Description

Returns the user’s interest level in a particular tag according to Personalization Engine.

 float horizon_interest( string tag )

Returns a floating-point number representing the level of interest that the current user has in the tag, where 1is the same level of interest as the average user on your site,2is twice as interested as the average user, and so on.

If you pass multiple tags separated by commas, the function will return the highest interest of any of the tags passed.

Example

{if horizon_interest('olympics,swimming') >= 2} 
<p>You might be interested in our coverage of the Olympics swimming team.</p> 
{/if}

Prompt Signup to Non-Subscribed Lists

Use Case: You manage your lists based on user variables and a Smart List (ex. Your  Technology List criteria is: Member of Master List, tech = 1). You’d like a one-click signup in each email for your users to add themselves to other lists based on user interest. You can do this by maintaining an array of your lists.

Zephyr:

In the Setup:

{set("allLists",[{"tags":["books"],"list":"Books","var":"books"},{"tags":["tech"],"list":"Tech","var":"tech"},{"tags":["politics"],"list":"Politics","var":"politics"},{"tags":["science","science-fiction"],"list":"Science","var":"science"},{"tags":["entertainment","celebrity"],"list":"Entertainment","var":"entertainment"}])}
{yourLists = []}

{foreach allLists as c}
{if profile.vars[c.var] == 1 || profile.vars[c.var] == "1"}
{push("yourLists", c.list)}
{/if}
{/foreach}

{listDelta = filter(allLists, lambda c: !contains(yourLists, c.list))}

In the Code:

<!--Showing only lists users are interested in-->
 {foreach listDelta as c}
 {if horizon_interest(c.tags) >= 2}
 Click here to sign up to <a href="http://example.com?sailthru_vars[{c.var}]=1">{c.list}</a>!<br/>
 {/if}
 {/foreach}

Output:

Click here to sign up to Books!

Click here to sign up to Tech!

Click here to sign up to Politics!

Click here to sign up to Science!

Explanation:

This script uses an array called “allLists”, which each item is an object with applicable interest tags (optional), the list name, and corresponding variable. An empty array called “yourLists” is then created, a foreach loop then iterates through the allLists array and checks the “profile” object. If the user has that corresponding custom field on their profile and it equals “1” in either the string or numerical data type, the list name gets pushed into the yourLists array, using the push() function. For instance, if a user has the “books” custom field equaling “1” on their profile, the “Books” list is added to their array.

Next, a local variable called “listDelta” is created, which users the filter() function to filter through the allLists array, keeping anything that’s not contained in the yourLists array, by using a bang (“!”), which acts as a “not statement,” in conjunction with the contains() function.

The listDelta array is then looped through in the Code. Using the horizon_interest function, the value of each tag is evaluated on a user-by-user basis. lf their interest score in that tag is greater than “2”, they will be prompted to sign up for that particular list, with the variable name automatically populating as the value of the “sailthru_vars” query parameter, which sets a custom field on a user upon click. When the user clicks, the variable us placed on their profile with the value of “1”, i.e. “science = 1″.

Use Case: You have content for both men and women, but you don’t collect this user variable. Thankfully, you tag your content with “men” and “women.” Based on users’ interest level, this will decide which hero banner should get shown.

Zephyr:

{if horizon_interest('women') > 5}
  <img src="women">
{else if horizon_interest('men') > 5}
<img src="men">
{else}
<img src="puppies">
{/if}

Explanation: This script uses the horizon_interest() function to see if a user is interested in women’s products based on a “women” interest tag. If so, a hero image showcasing women’s products is display. f they aren’t interested in women’s products, the script then checks to see if the user is interested in men’s content, using the “men” interest tag. Similarly, if the user is, a men’s hero image is displayed. If they’re interested in neither, a default image is shown. This is especially useful if you tag your content with gender tags and are not collecting gender as custom field.

Top