Expand my Community achievements bar.

SOLVED

Looking for custom script in Adobe DTM data element

Avatar

Former Community Member

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.

1 Accepted Solution

Avatar

Correct answer by
Level 4

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.

  1. <article class="mu-item">
  2. <a href="#">
  3. <div>
  4. <h1>This is a test text for tracking</h1>
  5. <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>
  6. </p>
  7. </div>
  8. </a>
  9. </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%"

 

View solution in original post

2 Replies

Avatar

Level 10

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 :-

https://helpx.adobe.com/dtm/kb/Event_Based_Data_Element_or_pass_custom_page_data_to_Data_Element.htm...

Thanks & Regards

Parit Mittal

Avatar

Correct answer by
Level 4

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.

  1. <article class="mu-item">
  2. <a href="#">
  3. <div>
  4. <h1>This is a test text for tracking</h1>
  5. <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>
  6. </p>
  7. </div>
  8. </a>
  9. </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%"