All Collections
Build in-app experiences
Additional Bento controls
Fire an event to your app via Bento-element click
Fire an event to your app via Bento-element click

For example, trigger the right upsell modal based on a user clicking "upgrade" in a Bento embedded card.

Emily Wang avatar
Written by Emily Wang
Updated over a week ago

One of the easiest ways to integrate actions in Bento with actions in your own app is via an event. Bento's CTAs (bottom of the step, special analytics) and inline buttons both support this.

Popular use cases

  • Open a modal in your app (that doesn't have a unique URL)

  • Animate an element on the page.

We recommend using CTAs because their clicks are tracked in analytics.

[Eng required] Receiving these events

To respond to these events, you'll need to add a document listener in your application javascript.

document.addEventListener('bento-buttonClicked', function(e) { if (e.detail.message === 'my-event-name') { // take action here } });

If you're using react hooks, you'd want to use the normal react useCallback/useEffect paradigm:

const bentoClickHandler = React.useCallback((e) => { if (e.detail.message === 'my-event-name') { // take action here } }, [ /* any dependencies used in the function */ ]); useEffect(() => { document.addEventListener('bento-buttonClicked', bentoClickHandler); return () => { document.removeEventListener('bento-buttonClicked', bentoClickHandler); } }, [bentoClickHandler]);
Did this answer your question?