--- title: "JavaScript Events Reference" slug: "javascript-events-reference" updated: 2026-06-23T13:13:41Z published: 2026-06-23T13:13:41Z canonical: "help.frisbii.com/javascript-events-reference" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.frisbii.com/llms.txt > Use this file to discover all available pages before exploring further. # JavaScript Events Reference The Frisbii Media JavaScript SDK communicates with the parent page exclusively via browser events. All events are dispatched on `document` and can be listened to with `document.addEventListener`. This page is a complete reference of all events across checkout, SSO, Snippets, and analytics. For usage examples see the individual feature articles. --- ## Checkout events ### `plenigo.PurchaseSuccess` Fired when the checkout flow ends — either after a successful payment, when the customer already owns the product, or when no purchase was possible due to rules. **Always check** `orderId` **to determine the actual outcome.** ```javascript document.addEventListener("plenigo.PurchaseSuccess", function(e) {    if (e.type !== "plenigo.PurchaseSuccess") return false;    var orderId = parseInt(e.detail.orderId);    if (orderId > 0) {        location.href = "/success/?order=" + orderId;    } else {        location.href ="/already-subscribed/";    } }); ``` | `e.detail` field | Type | Description | | --- | --- | --- | | `orderId` | integer | `> 0` = successful new purchase. `-1` = customer already owns this product. `-2` = product cannot be purchased based on configured rules. | | `customerSession` | string | Present when using Frisbii Media SSO checkout (`.login()` or `.register()`). Contains the customer session token. | | `data` | object | Any extra properties passed to the `config` object when starting the checkout are returned here. See [Passing additional data through the checkout](/frisbii-media/docs/checkout-1#passing-additional-data-through-the-checkout). | --- ### `plenigo.PurchaseFailed` Fired when a payment provider communication error causes the checkout to fail and recovery is not possible. **Recommendation: restart the checkout** (e.g. reload the page). ```javascript document.addEventListener("plenigo.PurchaseFailed", function(e) {    if (e.type !== "plenigo.PurchaseFailed") return false;    console.error("Checkout failed:", e.detail);    location.href = "/checkout-failed/"; }); ``` | `e.detail` field | Type | Description | | --- | --- | --- | | *(varies)* | | Error details from the payment provider. Log for debugging. | --- ### `plenigo.Error` Fired for unrecoverable errors that the customer cannot resolve without reloading the page. ```javascript document.addEventListener("plenigo.Error", function(e) {    if (e.type !== "plenigo.Error") return false;    console.error("Error:", e.detail.errorMsg);    location.reload(true); }); ``` | `e.detail` field | Type | Description | | --- | --- | --- | | `errorMsg` | string | Human-readable error message. | --- ## SSO events ### `plenigo.LoginSuccess` Fired when a login, registration, or password reset flow completes successfully. The `customerSession` must be passed to your backend to create a server-side session. ```javascript document.addEventListener("plenigo.LoginSuccess", function(e) {    if (e.type !== "plenigo.LoginSuccess") return false;    location.href = "/start-session/?session=" + e.detail.customerSession; }); ``` | `e.detail` field | Type | Description | | --- | --- | --- | | `customerSession` | string | Short-lived session token. Pass to your backend immediately. Use it to create a server-side session via `POST /sessions/customer` or pass directly to `preparePurchase`. | > [!NOTE] > This event is also fired by `plenigo.Checkout(...).login()` and `.register()`. In those cases `e.detail` additionally contains `orderId` and the checkout result fields. --- ## Web analytics events ### `plenigo.WebAnalyticsLoad` Fired every time a new page loads inside the checkout or SSO iframe. Use this to forward virtual page views to your analytics tool. ```javascript document.addEventListener("plenigo.WebAnalyticsLoad", function(e) {    console.info("Page loaded inside iframe:", e.detail);    // Forward to analytics, e.g. gtag('event', 'page_view', { page_title: e.detail.page }) }); ``` | `e.detail` field | Type | Description | | --- | --- | --- | | `page` | string | The page name that loaded inside the iframe. See the page name reference table in [Web Analytics Integration](/frisbii-media/docs/web-analytics-integration). | --- ## Summary table | Event | Triggered by | Key `e.detail` fields | | --- | --- | --- | | `plenigo.PurchaseSuccess` | Checkout completion (all outcomes) | `orderId`, `customerSession`*,* `data` | | `plenigo.PurchaseFailed` | Payment provider error | Error details | | `plenigo.Error` | Unrecoverable checkout error | `errorMsg` | | `plenigo.LoginSuccess` | SSO login / register / forgot password | `customerSession` | | `plenigo.WebAnalyticsLoad` | Any page load inside checkout or SSO iframe | `page` | * Present only in specific scenarios (see individual event descriptions above) --- ## Listening pattern All events follow the same listening pattern. Always check `e.type` at the start of your handler to avoid double-firing when multiple listeners are registered: ```javascript document.addEventListener("plenigo.PurchaseSuccess", function(e) {    if (e.type !== "plenigo.PurchaseSuccess") return false;    // ... your logic }); ``` --- ## Related - [Checkout](/frisbii-media/docs/checkout-1) - [SSO: Login & Registration](/frisbii-media/docs/sso-login-registration) - [Web Analytics Integration](/frisbii-media/docs/web-analytics-integration) - [Callback Events Reference](/frisbii-media/docs/webhook-events-reference)