# How do you send a variable to a bucket from a custom widget

**URL:** https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533
**Category:** Dashboards
**Created:** [January 29, 2024, 3:25pm UTC](https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533 "2024-01-29T15:25:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![agriot.info](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@agriot.info](https://community.tago.io/u/agriot.info)
#### Post date: [January 29, 2024, 3:25pm UTC](https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533/1 "2024-01-29T15:25:38Z")

</div>

Hi

I would like to send a variable created in a custom widget script to the bucket of the device where the data for the widget is coming from.

Thanks.

---

<div class="post-metadata">

### Author: ![freddy.minuzzi](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/freddy.minuzzi/32/415_2.png) [@freddy.minuzzi](https://community.tago.io/u/freddy.minuzzi)
#### Post date: [January 29, 2024, 8:01pm UTC](https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533/2 "2024-01-29T20:01:08Z")

</div>

Hi Shepard!

Take a look at this [article](https://community.tago.io/t/custom-widget-iframe) as it will help you send data via your custom widget. You’ll need to use the sendData function.

---

<div class="post-metadata">

### Author: ![agriot.info](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@agriot.info](https://community.tago.io/u/agriot.info)
#### Post date: [February 1, 2024, 5:29am UTC](https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533/3 "2024-02-01T05:29:30Z")

</div>

Hi Freddy

Thanks for the info. I have used this guide before and have managed to build a custom widget.  
The issue im having is in the guide they use a button to send the data to the bucket. I would like to send the data to the bucket dynamically depending on a condition.  
Something like this in the code snipet below:

```auto

/ Check if both distance and time conditions are met
            var movementStatus;
            if ((maxDistance >= circleRadius.value) && (timeElapsed < timeThreshold.value)) {
                // Significant movement - Apply your logic here
                console.log('Significant movement!');
                movementStatus = 'Moving';

                // Prepare data for sending
                var widgetData = {
                    variable: "movementStatus",
                    value: movementStatus
                };

                // Send data to TagoIO
                window.TagoIO.sendData(widgetData);

            } else {
                // Non-moving - Apply your logic here
                console.log('Non-moving!');
                movementStatus = 'Not Moving';

            }

```

---

<div class="post-metadata">

### Author: ![agriot.info](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@agriot.info](https://community.tago.io/u/agriot.info)
#### Post date: [February 1, 2024, 5:42am UTC](https://community.tago.io/t/how-do-you-send-a-variable-to-a-bucket-from-a-custom-widget/1533/4 "2024-02-01T05:42:59Z")

</div>

Do You think this should work, if so then i should look else where if its not working  
Thanks
