Expand my Community achievements bar.

SOLVED

Capturing sibling text of the clicked element through launch

Avatar

Community Advisor

We have a rule in Launch to capture a paragraph(".link.sl-cta.video") click in the DOM. We also want to capture the text present in sibling div when the paragraph is clicked. We tried the below custom code in the data element to get the sibling value. nothing works. Any help appreciated. Thanks


var text = $(this).parent().find(".content-block-heading").text();

console.log(text);
var text1 = $(this).siblings(".content-block-heading").text();

console.log(text1);

 

The rule is getting trigger when the link click happens

Saravanan_Dharmaraj_0-1664993301645.png

 

 

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Thanks for the reply. Plain javascript code didnt work.

 

Below one worked.

$(event.target).parent().find(".content-block-heading").text()

View solution in original post

3 Replies

Avatar

Community Advisor

i also read https://jimalytics.com/tag-management/adobe-launch-data-elements-guide/#Custom_Code 

$(this) - wont work in launch, so we have to use the utilities.. Could anyone point me to the doc where the utilities are mentioned? Thanks

Avatar

Level 4

It looks like jQuery is missing. But you can do this via regular javascript 

 

this.parentElement.querySelector(".content-block-heading").innerText

Avatar

Correct answer by
Community Advisor

Thanks for the reply. Plain javascript code didnt work.

 

Below one worked.

$(event.target).parent().find(".content-block-heading").text()