Expressions Replaced by Adobe Target Server

Avatar

Avatar
Boost 1
Level 1
kaio61751785
Level 1

Like

1 like

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
kaio61751785
Level 1

Like

1 like

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
kaio61751785
Level 1

30-12-2020

Using Form Composer we are attempting to use Template Literals as part of our code. But the expressions are being removed by Adobe Target's servers and never make it to the DOM.

 

Is there a way to tell Adobe Target not to make any server side substitutions?

 

Code we have got in a HTML offer, also tried to use backslashes to stop adobe server substitutions;

<script>
	let myText = 'The Text!';
	let theData = {
		moreText: 'This is more text!'
	};

	console.log(`\${myText}`);
	console.log(`${myText}`);
	console.log(`\\${myText}`);

	console.log(`${theData.moreText}`);
	console.log(`${theData.moreText}`);
	console.log(`\\${theData.moreText}`);

	console.log(`${theData['moreText']}`);
	console.log(`${theData['moreText']}`);
	console.log(`\\${theData['moreText']}`);
</script>

 

Screenshot of what gets injected into the HEAD by Adobe Target when preview link is loaded;

Screen Shot 2020-12-30 at 15.19.58.png

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 5
Level 2
ryanr7
Level 2

Likes

8 likes

Total Posts

13 posts

Correct reply

6 solutions
Top badges earned
Affirm 5
Affirm 3
Boost 5
Boost 3
Boost 1
View profile

Avatar
Affirm 5
Level 2
ryanr7
Level 2

Likes

8 likes

Total Posts

13 posts

Correct reply

6 solutions
Top badges earned
Affirm 5
Affirm 3
Boost 5
Boost 3
Boost 1
View profile
ryanr7
Level 2

05-01-2021

Hi @kaio61751785,

This is a good question! That syntax is used by Target for dynamic data in offers which is why it's getting removed/replaced. I couldn't find any info on how to "escape" the format for a literal print. However, I was able to hack a solution that worked for me you might try.

  • Create a profile script that returns the string you want returned like:

 

return "${myText}";​

 

 

ryanr7_0-1609893499031.png

 

  • Use the dynamic data sytax in your HTML offer to replace content with the value of your new profile script (I named mine "static").
    • HTML in offer example:

 

<script>
  let myText = 'The Text!';
  console.log(`${user.static}`);
</script>

 

 

When I run this my response from Target returns this:

ryanr7_1-1609893543052.png

And I see "The Text!" printed to the console. There may still be a better way to do this. But maybe this will help you out until you find the better way.

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 25
Employee
ryanr701
Employee

Likes

203 likes

Total Posts

224 posts

Correct reply

91 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 25
Employee
ryanr701
Employee

Likes

203 likes

Total Posts

224 posts

Correct reply

91 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile
ryanr701
Employee

05-02-2021

Hi @kaio61751785 ,

 

I came across another solution to this issue from another colleague (credit to Moritz K): his I believe is more elegant then my earlier option, and more scalable. The trick is to wrap the syntax around itself. When Target detects the nested instance of the syntax, it will replace the syntax with a new value (from the token name supplied) OR no value if none is found. Target only reads through one time for token replacement so the resulting syntax remains.

If I want the code from Target to have this literal output: 

 

console.log('${myText}');

 

Then I can enter this as my offer content:

 

console.log('$${false}{myText}');

 

Then Target will detect the "${false}" as a token and try to replace it. Since nothing with "false" exists in the Target profile it will remove that token and replace it with nothing. The result will be my end goal of: 

 

console.log('${myText}');

I think that's a bit nicer of a solution.