I am trying to capture HTML text value in DTM. There is a article tag which has the detail of the card. Once the User clicks on the card, the name of card (h1) tag will be reported. Below mentioned my code snippet.
<article class="mu-item"> <a href="#"> <div> <h1>This is a test text for tracking</h1> <p>This was the day when the South Stand at Old Trafford, the stadium where he played around half of his 758 matches for United, was officially renamed in his honour before his beloved Reds took on Everton in the Barclays Premier League.<br><br> </p> </div> </a> </article>
I have tried creating event based rule with data element but nothing is working fine. Can anyone please provide the right direction. should i have to create a data element or not. What should i define in my data element. do i have to use DTM custom scripts.
Solved! Go to Solution.
Views
Replies
Total Likes
amitj723 wrote...
I am trying to capture HTML text value in DTM. There is a article tag which has the detail of the card. Once the User clicks on the card, the name of card (h1) tag will be reported. Below mentioned my code snippet.
<article class="mu-item">
<a href="#">
<div>
<h1>This is a test text for tracking</h1>
<p>This was the day when the South Stand at Old Trafford, the stadium where he played around half of his 758 matches for United, was officially renamed in his honour before his beloved Reds took on Everton in the Barclays Premier League.<br><br>
</p>
</div>
</a>
</article>
I have tried creating event based rule with data element but nothing is working fine. Can anyone please provide the right direction. should i have to create a data element or not. What should i define in my data element. do i have to use DTM custom scripts.
In order to get the text from <h1> tags, in your event based rule for <h1> clicks, try using %this.@cleanText% as the value for your variable (See attached screenshot)
eVar1="%this.@cleanText%"
Views
Replies
Total Likes
Hi Amit ,
As per our understanding , you are trying to create an event based data element. Please refer the below article for creating the same :-
Thanks & Regards
Parit Mittal
Views
Replies
Total Likes
amitj723 wrote...
I am trying to capture HTML text value in DTM. There is a article tag which has the detail of the card. Once the User clicks on the card, the name of card (h1) tag will be reported. Below mentioned my code snippet.
<article class="mu-item">
<a href="#">
<div>
<h1>This is a test text for tracking</h1>
<p>This was the day when the South Stand at Old Trafford, the stadium where he played around half of his 758 matches for United, was officially renamed in his honour before his beloved Reds took on Everton in the Barclays Premier League.<br><br>
</p>
</div>
</a>
</article>
I have tried creating event based rule with data element but nothing is working fine. Can anyone please provide the right direction. should i have to create a data element or not. What should i define in my data element. do i have to use DTM custom scripts.
In order to get the text from <h1> tags, in your event based rule for <h1> clicks, try using %this.@cleanText% as the value for your variable (See attached screenshot)
eVar1="%this.@cleanText%"
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies