set

Welcome to our newly overhauled Zephyr pages! See our new Overview, Examples, and Index.
Feedback is welcome at bottom of each page.

Creates an array within a local template variable.

{set(string arrayName, ["value1","value2"])}

Note that this can also be accomplished by simply using the format {varName = [“value1″,”value2″]}.

Example

{set("testArray", ["item1","item2","item3"])}
{testArray[0]} = item1

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″.

Top