# Can we write custom events for custom components?

**URL:** <https://forum.builder.io/t/can-we-write-custom-events-for-custom-components/2387>\
**Category:** Technical Questions\
**Tags:** react, feature, custom-code, custom-components, nextjs\
**Created:** [July 14, 2022, 9:37am UTC](https://forum.builder.io/t/can-we-write-custom-events-for-custom-components/2387 "2022-07-14T09:37:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivela](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@olivela](https://forum.builder.io/u/olivela)\
**Post date:** [July 14, 2022, 9:37am UTC](https://forum.builder.io/t/can-we-write-custom-events-for-custom-components/2387/1 "2022-07-14T09:37:38Z")

</div>

Currently I have a custom component called ‘Menu’. To use this, a ‘Menu’ model is created, thus it gets tracked easily in insights as all models are tracked.

I also wish to track ‘Submenu’ which is a subfield for the custom component ‘Menu’.

How can I achieve that?

---

<div class="post-metadata">

**Author:** ![ancheetah](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ancheetah/32/751_2.png) [@ancheetah](https://forum.builder.io/u/ancheetah)\
**Post date:** [July 15, 2022, 4:17pm UTC](https://forum.builder.io/t/can-we-write-custom-events-for-custom-components/2387/2 "2022-07-15T16:17:35Z")

</div>

Hi @olivela, great question! You can track the submenu with a custom event which you can read more about in the link below. For example, if you want to track when the submenu item is clicked just add `builder.track('submenuClick')` to its `onClick` event.

> **[Tracking Custom Events - Builder.io](https://www.builder.io/c/docs/custom-analytics-dashboards)**
>
> Build and optimize digital experiences for any tech stack, visually.
