Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.

How to create three different click events in a single rule and identify in custom code which element triggered the click?

Avatar

Level 1

I have created three different element click events in one rule and want to retrieve the currently triggered element in custom code.

 

PrasanthDi_0-1734067880199.png

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Community Advisor

Hi @PrasanthDi  What is your use case? can you elaborate more 

 

In case if you just to understand from 3 different element, which element has clicked and get that value - you can write a small JS snippet like below. 

Suppose - you have 3 buttons with tag name called button 

<button>0</button>
<button>1</button>
<button>2</button>

 

and then you can iterate through them with using onClick function 

var buttons = document.getElementsByTagName('button');
for (var i = 0; i < buttons.length; i++) {
    (function (i) {
        buttons[i].onclick = function () {
            alert("button " + i + " was clicked");
        }
    }(i));
}

Here is the test fiddle : https://jsfiddle.net/x697pymu/ 

Check this once.

Thanks

Avatar

Level 1

Hi Gokul,

 

Thank you for your prompt response.

 

It is a single page application, On page load, the three buttons are not rendered yet. The button will display only when the modal is shown.

 

The rule gets triggered if i create the click event using the Adobe event type.

 

Please let me know if you need more details.

Avatar

Community Advisor

Hi @PrasanthDi  So are you using Web SDK for your implementation? Send Event method? Or is it normal implementation having Adobe analytics extension?