Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Capturing sibling text of the clicked element through launch

Avatar

Level 8

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
Level 8

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

Level 8

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
Level 8

Thanks for the reply. Plain javascript code didnt work.

 

Below one worked.

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