Expand my Community achievements bar.

SOLVED

Personalization block in Email subject

Avatar

Level 4

Hi All,

For my segmentation purpose, I am using a personalization block in my email delivery's subject line. Inside this personalization block, I am doing a soap call to fetch the subject appropriate for my segment. However, if after evaluation, if I get 'Hi <%= recipient.firstName %>' this recipient firstName part is not getting evaluated, rather i am getting the subject as 'Hi <%= recipient.firstName %>' not as 'Hi Jessie' (considering 'Jessie' is the recipient's first name).

Anyone has ever tried something like this? Any idea what I am doing wrong here?

Appreciate your response.

Thanks & regards

1 Accepted Solution

Avatar

Correct answer by
Level 2

In case it is of any interest to anyone, I was looking for a solution to this.

There is a function called evaluateTemplate() that would have worked for this, but it is not available in the delivery context, but only in a javascript workflow action.

So I manually searched and replaced the string that comes with personalization vars, similar to the following:

(This assumes that instead of <%= and %> the string comes with %JS_START% and %JS_END%. The reason I do this is that I want to _paste_ this code into a string, and having %> in a string will escape away from the _whole_ script)

<%

var dynamicSL = "%JS_START% recipient.firstName %JS_END%, today is %JS_START% formatDate(new Date(), '%Al')%JS_END%.";

var myRegEx = /%JS_START%.+?%JS_END%/g;

var evalPersonalization = function (str) {

   return eval(str.substr(10, str.length-18));

};

var finalSubjectLine = dynamicSL.replace(myRegEx, evalPersonalization);

%>

<%= finalSubjectLine %>

View solution in original post

6 Replies

Avatar

Level 3

Bonjour !

Cela fonctionne pour moi, j'ai une diffusion récurrente avec comme objet :

1396050_pastedImage_0.png

Avez-vous bien été chercher la variable en cliquant sur objet puis sur 1396051_pastedImage_1.png ?

Bonne journée,

Cordialement,

Marjorie

Avatar

Level 4

Hi,

As stated, I am using a personalization block within the 'Subject' line, so I cannot mention subject module as you've mentioned. In my personalization block, I am driving various logic and deciding on final o/p and I am evaluating the subject. At the o/p of my personalization block, I am getting output = 'Hi <%= recipient.firstName %>' and then I am using <%=subject %>, I am not getting 'Hi Jessie', instead I am getting 'Hi <%= recipient.firstName %>' - in a nutshell, using personalization block, it is not evaluating the tags

Avatar

Level 10

Hi,

I'm not 100% sure that personalization blocks can be inserted in subject lines, but you can still use variables as Marjorie explained, as well as conditionality (Conditional content). Would that be enough as a workaround?

Florent

Avatar

Level 2

supratim320​ Did you ever manage to find a solution for this issue? I'm facing the same problem. I'm pretty sure that eval'ing the string 'Hi <%= recipient.firstName %>'  won't work, so I'm looking into building a search-and-replace kind of solution where I check for probably just '<%='.

Avatar

Correct answer by
Level 2

In case it is of any interest to anyone, I was looking for a solution to this.

There is a function called evaluateTemplate() that would have worked for this, but it is not available in the delivery context, but only in a javascript workflow action.

So I manually searched and replaced the string that comes with personalization vars, similar to the following:

(This assumes that instead of <%= and %> the string comes with %JS_START% and %JS_END%. The reason I do this is that I want to _paste_ this code into a string, and having %> in a string will escape away from the _whole_ script)

<%

var dynamicSL = "%JS_START% recipient.firstName %JS_END%, today is %JS_START% formatDate(new Date(), '%Al')%JS_END%.";

var myRegEx = /%JS_START%.+?%JS_END%/g;

var evalPersonalization = function (str) {

   return eval(str.substr(10, str.length-18));

};

var finalSubjectLine = dynamicSL.replace(myRegEx, evalPersonalization);

%>

<%= finalSubjectLine %>

Avatar

Level 4

Yes, that's the only way I could find