내 커뮤니티 업적 표시줄을 확대합니다.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.
해결됨

Custom code to track link name in adobe launch.

Avatar

Level 6

I know how to track link click using click event  using css selector in adobe launch. But I am trying to get a custom code that can be used in adobe launch to listen for link click and then get link name from that link and store it in evar and prop and custom link name. Can somebody throw a code just link that? Actually I am challenging myself to make use of custom js code.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

Personally, I would always try to avoid Custom Code. While you can just use

return event.element.innerText;

as Custom Code, doing it within a Data Element in the UI is much clearer and more accessible to many users. It's a personal preference, but going the UI-route has always payed off for me.

Learn more about Adobe Analytics and Customer Journey Analytics on my blog

Need help with Adobe Analytics or Customer Journey Analytics? Let's talk!

원본 게시물의 솔루션 보기

8 답변 개

Avatar

Community Advisor and Adobe Champion

With the click event, information about the clicked element gets attached to the Event Object automatically. From there, it is very easy to pick up using a Constant Data Element. The innerText attribute might be the right one for your use case, which can be accessed as "%event.element.innerText%":

FrederikWerner_0-1676896388306.png

It's also featured in this tutorial I've done a while back, you can find the video here: https://youtu.be/VRi3WdwkA3g?t=513

Learn more about Adobe Analytics and Customer Journey Analytics on my blog

Need help with Adobe Analytics or Customer Journey Analytics? Let's talk!

Avatar

Level 6

Wow man send me more such videos so that I can get comfortable using custom codes.

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

Personally, I would always try to avoid Custom Code. While you can just use

return event.element.innerText;

as Custom Code, doing it within a Data Element in the UI is much clearer and more accessible to many users. It's a personal preference, but going the UI-route has always payed off for me.

Learn more about Adobe Analytics and Customer Journey Analytics on my blog

Need help with Adobe Analytics or Customer Journey Analytics? Let's talk!

Avatar

Level 6

But what If I have buttons to be tracked instead of links.

Avatar

Community Advisor and Adobe Champion

The innerText attribute should still work, but a lot can be done in HTML that is not exactly compliant with standards. Check out pages like https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText to get an idea of which attributes to use. If the display text is kept completely outside of the element, you might need to get a bit creative.

Learn more about Adobe Analytics and Customer Journey Analytics on my blog

Need help with Adobe Analytics or Customer Journey Analytics? Let's talk!

Avatar

Level 6

This worked like a charm. So %event.element.innerText% is this tag a standard one which can be used any where? Is this something like what we write for direct call rule?

Avatar

Community Advisor and Adobe Champion

It is very universal and should work in many places! You can find some more inspiration on the mentioned links.

Learn more about Adobe Analytics and Customer Journey Analytics on my blog

Need help with Adobe Analytics or Customer Journey Analytics? Let's talk!

Avatar

Level 1

Could you please explain how to write a single JavaScript code using document.getElementsByClassName that captures the name of the button whenever a user clicks it anywhere on the website and store it in evar and prop and custom link name?