# How do button add a metric?

**URL:** <https://meta.discourse.org/t/how-do-button-add-a-metric/160519>\
**Category:** Development\
**Created:** [August 11, 2020, 6:44pm UTC](https://meta.discourse.org/t/how-do-button-add-a-metric/160519 "2020-08-11T18:44:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev\_Work](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dev_work/32/124200_2.png) [@Dev\_Work](https://meta.discourse.org/u/Dev_Work)\
**Post date:** [August 11, 2020, 6:44pm UTC](https://meta.discourse.org/t/how-do-button-add-a-metric/160519/1 "2020-08-11T18:44:24Z")

</div>

Here’s my the button

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

```

How do I add this code to it

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

```

---

<div class="post-metadata">

**Author:** ![Dev\_Work](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dev_work/32/124200_2.png) [@Dev\_Work](https://meta.discourse.org/u/Dev_Work)\
**Post date:** [August 11, 2020, 6:48pm UTC](https://meta.discourse.org/t/how-do-button-add-a-metric/160519/2 "2020-08-11T18:48:46Z")

</div>

This should look in the source code

 ![2020-08-11_214650](https://global.discourse-cdn.com/meta/original/3X/a/d/ad4622153d27a3557904387bab4e446d3dd4c3b9.png)
