append_user_var

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

Description

Add values to an array on a user’s profile from a campaign or transactional send. This is useful for recording the top personalized content sent to a user in order to prevent it from being a featured item in that user’s future sends. Note that the personalize function will automatically exclude the user’s last 30 visited URLs.

This feature must be activated on your account in order to function in email sends. Please contact your Customer Success Manager with your requirements to request its enablement.

 list append_user_var( string var_name , mixed new_value [,int cap ] )

New values will be added to the start of the given array. The oldest value will be removed if the total number of items exceeds the cap.

  • var_name – Name of the array. An array by this name will be created if it does not exist.
  • new_value – The value to add to the array var_name on the user’s profile. (Can be a string, numerical, or boolean value.)
  • cap – How many items var_name can hold before the oldest items are removed. The default is 15 and max is 30.

Within a given user’s send, append_user_var() can only be used once per array and up to 10 times total (each for a different array).

Example

Save the ID of the Personalization Engine-selected “top story” that is sent to the user, adding it to a top_stories array on the user’s profile.

{append_user_var('top_stories', content[0].unique_id, 30)}
To leverage this to prevent duplicate top stories across multiple sends to a given user, you could use the following workflow within your template code:
  1. Filter the content array (which contains the latest items from the template’s feed) to eliminate any items that match an ID previously added to the user’s top_stories array.
    {content = filter(content, lambda c: !contains(profile.vars.top_stories, c.unique_id))}
  2. Get the top ten items from the filtered content array, personalized for the user by Sailthru’s Personalization Engine.
    {content = horizon_select(content, 10)}
  3. Assuming that the first item in the newly personalized content array is the new ‘top story’ you will display, add its ID to the top_stories array, so that it will not be displayed as the top story in future sends.
    {append_user_var('top_stories', content[0].unique_id, 30)}
Top