Use helper functions for personalization
Learn how to transform personalization values using personalization helper functions and understand different use cases for helper functions.
Transcript
By the end of this video, you should be able to use Helper Functions to assist in creating personalized content in your Journey Optimizer messages.
When working in personalization, there are times when you may want more control over the display of different attributes. For instance, you may want a particular value to appear in all caps or all lowercase. There may be certain attributes that you want to use for personalization, but you鈥檙e unsure if the majority of your profiles will have an existing value for it. So, you may want to insert a condition to first check and see if the value is no. You may want to construct if then conditions where you can change what appears in the message based on the conditional value of an attribute. Another use could be in grabbing a list of items where you want to display values for each. For all of these scenarios and many others you鈥檒l want to use the Helper Functions and the personalization editor. Let鈥檚 take a look.
In this example, I have a Journey Optimizer message that will be sent to a customer if they鈥檝e left some items in their shopping cart, but have not completed the purchase. I鈥檝e noticed that in the design of this message the first name should appear in all caps to match the rest of this section. To ensure that that will happen I鈥檓 going to use a Helper Function to transform the name, to always be uppercase. I鈥檒l click the Edit Personalization button. And in the Edit Personalization window, I鈥檒l choose Helper Functions from the dropdown menu. In the search box, I鈥檓 going to search for uppercase.
I鈥檒l navigate into the folder and I want to click the information button to learn a little more about this function. I can see that this function will convert a string to uppercase. I鈥檒l go ahead and insert this function, and I鈥檓 going to replace the string with the first name value. So, I鈥檒l navigate back over to the file section and search for first name.
And I鈥檒l click plus sign to insert that.
Then I can click save.
Down below I have a section where I want to list the items in the cart. So, I鈥檒l jump into HTML edit mode first, and what I鈥檒l do is I鈥檒l replace any static values with the right contextual attributes.
Let鈥檚 see.
Okay, first, I鈥檓 going to switch to context and I鈥檓 going to replace the Image URL.
Next I鈥檓 going to add the total.
I鈥檒l in the product name, and the quantity.
Great, now that I鈥檝e removed the static values with the correct contextual attributes, I want to make sure that I can repeat this block for any products that have been added to the cart.
So, to do that, I鈥檓 going to switch back over to Helper Functions. And I鈥檓 going to search for the each function.
I鈥檒l click the plus sign to insert the function. And looking at this particular helper, I can see that it鈥檚 looking for someArray and variable. someArray is going to be the list that I want to search for, and variable will be the item that I want to repeat. So, I鈥檓 going to first get rid of the someArray, and I will replace that with my product list context.
Okay, for the variable I want to actually use product as my main item.
Just remove the dot there, get rid of these.
And the next thing I want to do is I want to take the ending each tag, and I鈥檓 going to place it below the bottom of this block.
So that I know this whole item is going to be repeated for each product, this whole section.
Or validate that just to make sure there are no errors, and then I鈥檒l click save.
Another user Helper Functions could be in this block here. So, I want to make sure that the customer sees any special product notes for a particular product. In this case, I want to make sure that the customer knows that if they order the Juno jacket, that there鈥檚 a two-week lead time on shipping.
So, I already have my block design with the product notes, I want to make sure that this is only displayed if one of the products in the cart is the Juno jacket. For this, I鈥檓 going to use the if Helper Function. Let鈥檚 jump back into HTML Edit Mode.
And what I鈥檓 going to do is at the top of this block, I鈥檓 going to choose Helper Functions and I will search for if.
I鈥檒l click the plus sign to insert the function. And I can see that it鈥檚 going to check first for condition.
Then it鈥檚 going to give me the option to add the content. And then there鈥檚 a follow-up else condition and then a default render followed by a closing if tag. So, what I鈥檓 going to do is I鈥檓 going to actually remove the multiple else鈥檚, and I鈥檓 going to take this and I鈥檓 going to select it. And I鈥檓 actually going to place it at the bottom of this block.
So, the condition I want to check for is if the product here is the Juno jacket, this has the Juno jacket in their cart. So, I鈥檓 going to search for name and add the product name here and I鈥檒l do an equal sign.
Okay, so this is going to say if the product name here is Juno jacket, then go ahead and show this entire block. If not, let鈥檚 go ahead and not show anything so the whole block would disappear.
All right, will validate this make sure there are no errors and then I can click save.
All right, that should be it. Let鈥檚 take a look at how these Helper Functions worked in my emails. So in this first email, I can see that the customer name Brenda has been transformed to all uppercase and the each function is now showing all the different items that were left in the cart. Because the Juno jacket is not one of these items I am not seeing those special product notes that we had conditionally added to indicate that there was a two week lead time in shipping that particular product.
Looking at this second email, I can see that because the Juno jacket is one of the items in this shopping cart list. I now received the product notes indicating the lag in ship time.
You should now be able to use Helper Functions to assist in creating personalized content in your Journey Optimizer Messages. -
See the product guide to learn more about helper functions.
recommendation-more-help
7e382214-bd30-4de2-bc8b-f6f6e7182305