How do button add a metric?

Here’s my the button

    buttons.push(this.attach('button', {
      label: 'log_in',
      className: 'btn-primary login-button',
      action: 'showLogin'
    }));

How do I add this code to it

.setAttribute('onclick', "ym(XXXXXXXX, 'reachGoal', 'login_button'); return true;")

This should look in the source code
2020-08-11_214650