Expand my Community achievements bar.

Never miss an update of the Adobe Journey Optimizer Community Lens! Subscribe now to get the latest updates, insights, and highlights delivered straight to your inbox every time a new edition drops.
SOLVED

How to use variable in content template in ajo

Avatar

Level 9

I am trying to create a variable in HTML and use the value in multiple places in HTML. 

{% let Linktags = "abc,def" %}

<a href="https://www.qatarairways.com/" 
   target="_blank" 
   data-tags="{{ Linktags }}"
   style="color:#8C919B; text-decoration:underline;"
   data-tracking-type="MIRROR_PAGE" 
   data-nl-type="mirrorPage">
   View in browser
</a>

 

I validated this HTML and there is no syntax issue but it is treating like string  data-tags="{{ Linktags }}". instead of getting value from actual variable. I also tried below syntax but it is not working. Any idea how to make this work ?

 
<a href="https://www.qatarairways.com/" 
   target="_blank" 
   data-tags="{%=Linktags %}"
   style="color:#8C919B; text-decoration:underline;"
   data-tracking-type="MIRROR_PAGE" 
   data-nl-type="mirrorPage">
   View in browser
</a>

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Mario248 ,

 

As I know, In AJO, personalization inside content templates is powered by a Handlebars-based expression language.

That means:

1. You cannot define or assign your own variables in the template using syntax like `{% let ... %}` or `{%= ... %}` — these are not supported in AJO.

2. You can use either:

- Hardcoded (static) strings.
- Dynamic data coming from your profile, event, or context attributes, for example:

- Predefined functions.

 

Doc URL: https://experienceleague.adobe.com/en/docs/journey-optimizer/using/content-management/personalizatio...

 

Hope it will help you.

 

Kr,

Parvesh

Parvesh Parmar – Adobe Community Advisor
https://www.linkedin.com/in/parvesh-parmar/

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @Mario248 ,

 

As I know, In AJO, personalization inside content templates is powered by a Handlebars-based expression language.

That means:

1. You cannot define or assign your own variables in the template using syntax like `{% let ... %}` or `{%= ... %}` — these are not supported in AJO.

2. You can use either:

- Hardcoded (static) strings.
- Dynamic data coming from your profile, event, or context attributes, for example:

- Predefined functions.

 

Doc URL: https://experienceleague.adobe.com/en/docs/journey-optimizer/using/content-management/personalizatio...

 

Hope it will help you.

 

Kr,

Parvesh

Parvesh Parmar – Adobe Community Advisor
https://www.linkedin.com/in/parvesh-parmar/

Avatar

Level 1

Hi Parvesh,

 

Has a deep analysis been made about this topic? 
Since the URL provided contains the "utm_source" parameter equal to "chatgpt.com", I am afraid it didn't.

 

Can you please give us more details about how data-tags can be set dinamically inside the html?

 

Thank you,

 

Mario

Avatar

Level 1

Hi,

I have exactly the same issue and I tried the following tests:

- data-tags="{{variable}}"

- data-tags="{{{variable}}}"

- data-tags={{variable}}

- data-tags={{{variable}}}

- data-tags="{{profile._tenant.attribute}}"

- data-tags="{{{profile._tenant.attribute}}}"

- data-tags={{profile._tenant.attribute}}

- data-tags={{{profile._tenant.attribute}}}

- data-tags="{{store._tenant.lookupAttribute}}"

- data-tags="{{{store._tenant.lookupAttribute}}}"

- data-tags={{store._tenant.lookupAttribute}}

- data-tags={{{store._tenant.lookupAttribute}}}

 

Where store._tenant.lookupAttribute is an attribute of a dataset enabled for lookup.

 

None of them works. Am I mistaking something? Otherwise it seems it is not true that dynamic data can be used.

Perhaps, I am experiencing this issue only in data-tags (dynamic href, instead, is OK).

 

Thanks,

 

Mario