Reputation: 13
I want to track link clicks so i've set up a tag with the label as {{Click Text}}
However, if I have the following html, it returns "Hello World I dont want this text"
<a href="http://example.com">
Hello World
<span><p> I dont want this text </p></span>
</a>
How do I exclude "I dont want this text" from the result?
Thanks
Upvotes: 1
Views: 1323
Reputation: 8736
I presume that you have a trigger with type Click-Just Links
. Then, to achieve only Hello World
in your tag you need to do the following:
1) Create Variable:
Type: Custom Javascript
Code: function () {return $({{Click Element}}).clone().children().remove().end().text();}
Name: Click Text Without Children
2) In your trigger, you can use variable {{Click Text Without Children}}
which will return only Hello world
for you
Upvotes: 2