> For the complete documentation index, see [llms.txt](https://subify-1.gitbook.io/sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://subify-1.gitbook.io/sdk/subify-sdk-for-developers/events.md).

# Events

## subify:sdkLoaded

This event will be triggered when sdk is successfully loaded.

```javascript
window.addEventListener("subify:sdkLoaded",()=>{
  //sdk is loaded and you can access to 'window.subifySdk'
   })
```

{% hint style="warning" %}
Please note that this event is only triggered when the Subify SDK has not yet been loaded. If you listen to this event after the Subify SDK has been loaded, it won't be triggered. You can check “window\.subifySdk” to determine whether the SDK has been loaded previously.
{% endhint %}

## subify:variantChange

This event will be triggered when sdk detects variant selection.

<pre class="language-javascript"><code class="lang-javascript"><strong> window.addEventListener("subify:variantChange", (event) => {
</strong>//you have access targetProductId and selectedVariantId in event.detail
      const { targetProductId, selectedVariantId } = event.detail;

    });

</code></pre>

**`event.detail`**

| targetProductId   | (number) The ID of the product whose variant has changed. |
| ----------------- | --------------------------------------------------------- |
| selectedVariantId | (number) the ID of new selected variant                   |

## subify:sellingPlanChange

This event will be triggered when the user changes a subscription option in the widget.

```javascript
window.addEventListener("subify:sellingPlanChange", (event) => {
//you have access targetProductId and selectedSellingPlan in event.detail
      const {targetProductId, selectedSellingPlan } = event.detail;

    });
    
```

**`event.detail`**

| targetProductId     | (number) The ID of the product whose selling plan has changed.                                                                                                               |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| selectedSellingPlan | Selected selling plan that is a Shopify[ selling plan object](https://shopify.dev/docs/api/liquid/objects/selling_plan) or null if the user selects one time purchase option |
