Expand my Community achievements bar.

The 5th edition of the Campaign Community Lens newsletter is out now!
SOLVED

Personalization field in script

Avatar

Level 2

Hi,

I have a script in an email template which I want to populate with the name and email of the recipient. How may I do that? See the script below where I have tried to add the personalization field but I am not sure of the format. Now it will just be formatted as text.

<script type="application/json+trustpilot">
{
"recipientName": "<span class="acr-field nl-dce-field" data-nl-expr="/context/targetData/name" data-nl-type="string" contenteditable="false">Name (name)</span>",
"recipientEmail": "<span class="acr-field nl-dce-field" data-nl-expr="/context/targetData/email" data-nl-type="string" contenteditable="false">Email (email)</span>"
}
</script>

 

Br

Filip

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Filip, 

 

The notation you used is generally just for email content, you may want to call the variables using this format instead:

Where firstname: <%= context.targetDate.name%> .

 

In the script that would be:

 

<script type="application/json+trustpilot">
{
"recipientName": "<%= context.targetDate.name%>",
"recipientEmail": "<%= context.targetDate.email%>"}
</script>

 

This is the way variables are called in Campaign Classic, and I've used it with success in Standard too. 

Please let me know how it goes.

 

Cheers,

Jamal

2 Replies

Avatar

Correct answer by
Level 2

Hi Filip, 

 

The notation you used is generally just for email content, you may want to call the variables using this format instead:

Where firstname: <%= context.targetDate.name%> .

 

In the script that would be:

 

<script type="application/json+trustpilot">
{
"recipientName": "<%= context.targetDate.name%>",
"recipientEmail": "<%= context.targetDate.email%>"}
</script>

 

This is the way variables are called in Campaign Classic, and I've used it with success in Standard too. 

Please let me know how it goes.

 

Cheers,

Jamal