Script injection in React SPA application using Triggerview function
- July 13, 2023
- 1 reply
- 1651 views
Hello there,
I've recently set up/upgraded to at.js 2.x on our React Application (Using Adobe Node SDK on the server side) and using TriggerView to invoke the campaign. The problem is - Currently we have an element on the page(SPA) with a few cards with buttons and every time each button is clicked it loads data from our Database(JSON) but all 3 button clicks will generate DOM with the same class name and similar structure. My question is - how to differentiate each button clicks on the Target/server side to inject different content for an AB test because if I target classname it will load the same data from my script for all 3 button clicks?
I have attached the sample screenshot below. When someone clicks on the button on each card it will open up another card(like a modal popup) with different data coming from DB with similar DOM.
The goal is to AB test different data for different locations using Target.
Thanks and I would appreciate any help 🙂
Example of the structure below:
The links for href and text are coming from DB as a JSON object.
Card 1
<p class="popupWrapper ">Sample Heading</p>
<ul id="Menu1">
<a href="https://adobe.com/#1" target="_blank">
<li class="listeitem">Item number 1</li></a>
<a href="https://adobe.com#2" target="_blank">
<li class="listeitem">Item number 2</li></a>
<a href="https://adobe.com#3" target="_blank">
<li class="listeitem">Item number 3</li></a>
</ul>
<button type="button" class="btnClass">Button 1</button>
Card 2
<p class="popupWrapper ">Sample Heading</p>
<ul id="Menu1">
<a href="https://target.com/#1" target="_blank">
<li class="listeitem">Second card item 1</li></a>
<a href="https://target.com#2" target="_blank">
<li class="listeitem">Second card item number 2</li></a>
<a href="https://target.com#3" target="_blank">
<li class="listeitem">Second card item number 3</li></a>
</ul>
<button type="button" class="btnClass">Button2</button>