Question regarding when the script runs in Target for A/B Test | Community
Skip to main content
aaronlng_92
Level 2
December 2, 2022
Solved

Question regarding when the script runs in Target for A/B Test

  • December 2, 2022
  • 2 replies
  • 1387 views

Hello everyone. I'm working on a project where I have to dynamically change the text of a set of buttons across a site for an A/B test. The problem I am facing is the content is dynamically generated with a script in the body of the HTML, so whenever I try to update with custom code, it runs in the head and does not update the content. Does anyone have any suggestions or has performed a similar function in a test in Target?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JacobTo1

If possible, I would recommend using the at.js 2.x library and using a triggerView() to apply changes once the dynamic content has been rendered.

The other benefit of this approach is your offers will be "prefetched" on the initial page load.

 

These docos have more detail:

Target v2 Launch Extension - https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/target-v2/overview.html 

Using VEC on SPA's - https://experienceleague.adobe.com/docs/target/using/experiences/spa-visual-experience-composer.html 

2 replies

ambikaTewari_ATCI
Community Advisor
Community Advisor
December 5, 2022

Hi @aaronlng_92 you need to write the javascript code  in the code editor. you can use the setInterval function to check and get the value of button label. 

Once you get it, you can use the value to replace button label/text.

 

JacobTo1Accepted solution
Level 4
December 13, 2022

If possible, I would recommend using the at.js 2.x library and using a triggerView() to apply changes once the dynamic content has been rendered.

The other benefit of this approach is your offers will be "prefetched" on the initial page load.

 

These docos have more detail:

Target v2 Launch Extension - https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/client/target-v2/overview.html 

Using VEC on SPA's - https://experienceleague.adobe.com/docs/target/using/experiences/spa-visual-experience-composer.html