ID of a button (?)

Hello

I want to know

How can I change or assign an ID to a current button?

Thanks!

I don’t see where to change or assign a unique ID, to identify it.

1 Like

Be sure ‘Dev mode’ is on, click on button then you should see a box containing the id (#button) with selections for event handlers. You can edit the ID now.

1 Like

Thanks for the reply

I imagined it was that.

But the unique ID to identify a particular button, how can it be done?

I want to be able to measure how many clicks each button has from GTM and Google Analytics.

This ID is in the two buttons

$w('Button').onClick(async(event)=>{
    let btnID = event.target.id; 
    console.log("Button-    ID: ", btnID);
    //----------------------------------------------------------------------------
    switch(btnID) {
       case "buttonID_1":       function1_here(); console.log("Button-1 clicked!"); break;
       case "buttonID_2":       function2_here(); console.log("Button-2 clicked!"); break;
       case "buttonID_3":       function3_here(); console.log("Button-3 clicked!"); break;                                                                                                                                                             
       //--------------------------------
       default: // code block
   }
});
function function1() {/*do what ever you want here*/}
function function2() {*/do what ever you want here*/}
function function3() {*/do what ever you want here*/}

Hi,
I did try to change a button ID, but it still won’t show in the source code. It’s just changing the ID and then click on “publish”? What am I missing?
Thanks!