“Profile” Object

Within any Zephyr context, the profile object contains a number of useful pieces of data about the current user. This is a sample profile object:
{   
   "id" : "4d915c32cc0c1adbb141b547" ,   
   "email" : "example@example.com" ,   
   "lists" : [ "List A" , "List B"] ,   
   "lists_signup" : { "List A" : 1302864589 , "List B" : 1302164760} ,
   "vars" : { "name" : "Joe Smith" , "gender" : "M"} ,   
   "signup_time" : 1302164760 ,   
   "open_time" : 1311284816 ,   
   "click_time" : 1311521398 ,
   "horizon_time" :  1309366345  
   "purchase_time" : 1309366347 ,   
   "purchases" : [ { 
         "id" : "4e0b584b6763d9eb550002e3" ,       
         "items" : [ { "qty" : 1 ,                     
                       "title" : "Rectangle Earrings Gold " ,                     
                       "price" : 2520 ,                     
                       "id" : "10081-0020" ,                     
                       "url" : "http://example.com/sale/132/product/1917/" ,
                       "images": {"thumb": "https://example.com/path-to-thumb-img.jpg", "full": "https://example.com/path-to-full-img.jpg"}
                       "tags" : [ "jewelry" , "gold" , "earrings"] ,                     
                       "vars" : { "supplier_name" : "Melissa Smith Design"}                    
                     } ,                    
                     { "qty" : 1 ,                      
                       "title" : "Flower Set Steel" ,                      
                       "price" : 2360 ,                      
                       "id" : "10081-0032" ,                      
                       "url" : "http://example.com/sale/132/product/1951/" ,                      
                       "tags" : [ "jewelry" , "stainless-steel" ] ,                      
                       "vars" : { "supplier_name" : "Melissa Smith Design"}}                 
                   ] ,        
          "price" : 4880 ,        
          "qty" : 2 ,        
          "time" : 1309366347}    
   ] , 
   "return_time" : 1485457143 ,  
   "returns" : [ {  
         "id" : "588a46f715dd96dc758b5918",
         "price" : 2520,
         "qty" : 1,
         "time" : 1485457143,
         "items" : [ {  
               "url":"http://example.com/sale/132/product/1917/",
               "price":2520,
               "qty":1,
               "id":"10081-0020",
               "order_id" : "4e0b584b6763d9eb550002e3"
            } ]
    } ], 
   "purchase_incomplete" : {        
          "id" : "4e2af8356763d95a5e000b6d" ,        
          "items" : [ {             
                "qty" : 1 ,             
                "title" : "4 Lattice Kitchen Towels " ,             
                "price" : 1400 ,             
                "id" : "10027-0035" ,             
                "url" : "http://example.com/sale/570/product/4363/" ,             
                "tags" : [ "kitchen" , "towels"] ,             
                "vars" : { "supplier_name" : "Acme Group"}         
          }] ,         
          "price" : 1400 ,         
          "qty" : 1 ,         
          "time" : 1311438901    
   }
   "keys" : {
          "extid" : "123456789",
          "sms" : "+17775551212",
          "twitter" : "myhandle",
   }
}
These are the fields contained in the profile object:
Field Type Description
id string Unique identifier for this particular user
email string Email address of this user; also part of the global scope as {email}
lists array List of the natural lists that this user belongs to
lists_signup object The signup times for each particular list
vars object Vars set on this particular user; vars are also part of the global context scope
optout string Current optout status of the user; can be set to all , basic or blast.
signup_time integer UNIX timestamp of the earliest list signup time of this user
open_time integer UNIX timestamp of the most recent time the user last opened a message
click_time integer UNIX timestamp of the most recent time the user clicked a message
horizon_time integer UNIX timestamp of the most recent time the user viewed a webpage on your site (Personalization Engine required)
purchase_time integer UNIX timestamp of the most recent purchase by the user
purchases array List of the last 100 completed purchases of the user
return_time integer UNIX timestamp of the most recent return by the user
return array List of the last 100 purchase returns of the user
purchase_incomplete object The current contents of the user’s shopping cart
keys object Additional key values for the profile (requires activation via your Account Manager), e.g. extid, fb, twitter, sms, etc.
To access the values of these fields in the profile object, you can use “dot” . notation.

Examples

Check if a user is opted out. 
{if profile.optout}
   Click here to opt back in. 
{/if}
Check if a subscriber is a member of a list, using the contains() function:
{contains(profile.lists,"Main")}
In a template, call in today’s purchases. {profile.purchases} should contain all carts that a user has ever checked out with. Items refer to the contents of that cart at checkout. If you wanted to get all items purchased for a particular day you might do something along the lines of:
{items = []}
{todays_carts = filter(profile.purchases, lambda p: date("yyyy-MM-dd",p.date) == date("yyyy-MM-dd"))}
{foreach todays_carts as cart}
    {foreach cart.items as item}
        {items = items + list(item)}
    {/foreach}
{/foreach}
In a template, call in the most recent purchase:
{purchases = sort(profile.purchases, "-time")}
{purchases[0]} {* most recent purchase *}
User vars (a.k.a. custom fields) can be referenced one of two ways (either produces the same behavior):
{customvariable} or {profile.vars.customvariable}

Contact us

Top