Articles on: Bundles

JavaScript events for enhanced customer experience

Loop has introduced 31 unique JavaScript (JS) custom events that are triggered by various actions within the customer portal and bundle builder screen. This new functionality allows store developers to curate customized experiences for users by leveraging these events.

This article will cover the following topics:

Popular use cases for custom events
Setting up event listeners
List of custom events
Need help?



These custom events can be utilized for a variety of purposes, such as:

Sending contextual communications: Trigger cart abandonment emails when a customer adds an item on their bundle builder page but doesn't actually add the bundle to the cart.
Triggering surveys or forms: Automatically display a Net Promoter Score (NPS) form when a customer adds a product from the upsell section.
Tracking behavioural data: Monitor how users interact with the portal by tracking actions like product additions, updates, or deletions.


Setting up event listeners



To begin using these JS events, developers need to set up event listeners in their code. These listeners will detect when specific actions occur and trigger corresponding custom flows. Here's a basic example of how you can set up an event listener:

window.addEventListener('loopAddAsOneTime', () => { // Insert code here to trigger the custom experience });


This sample code listens for the loopAddAsOneTime event. When this event is triggered, it will execute the function defined inside the event listener, where you can place code to initiate any custom behaviour.


List of custom events



The JS events you can utilize are categorized into four groups based on the type of interaction they represent:

Customer portal events


Product-based events
- loopAddAsOneTime: Triggered when a product is added as a one-time purchase.
- loopAddAsSubscription: Triggered when a product is added on a subscription basis.
- loopRemoveForOneTime: Triggered when a one-time product is removed.
- loopRemoveFromSubscription: Triggered when a subscription product is removed.
- loopProductSwap: Triggered when a product swap is made.
- loopUpdateProductQuantity: Triggered when the quantity of a product is updated.

Subscription-based events
- loopAddDiscount: Triggered when a discount is applied to a subscription.
- loopRemoveDiscount: Triggered when a discount is removed.
- loopChangeSubscriptionPlan: Triggered when a subscription plan is changed.
- loopChangeDeliveryMethodRequested: Triggered when a change in delivery method is requested.
- loopEditDeliveryDetails: Triggered when delivery details are edited.
- loopUpdatePaymentMethodRequested: Triggered when an update to the payment method is requested.
- loopCancelSubscription: Triggered when a subscription is canceled.
- loopReactivateSubscription: Triggered when a subscription is reactivated.
- loopPauseSubscription: Triggered when a subscription is paused.
- loopResumeSubscription: Triggered when a subscription is resumed.

Order-based events
- loopOrderNow: Triggered when an order is placed immediately.
- loopSkipNextScheduledOrder: Triggered when the next scheduled order is skipped.
- loopSkipFutureScheduledOrder: Triggered when future scheduled orders are skipped.
- loopRescheduleNextOrder: Triggered when the next order is rescheduled.
- loopDelayNextOrder: Triggered when the next order is delayed.
- loopUnskipOrder: Triggered when a previously skipped order is reinstated.

Bundle-based events
- loopBundleAddAsOneTime: Triggered when a bundle is added as a one-time purchase.
- loopBundleAddAsSubscription: Triggered when a bundle is added on a subscription basis.
- loopBundleRemoveForOneTime: Triggered when a one-time bundle is removed.
- loopBundleRemoveFromSubscription: Triggered when a subscription bundle is removed.
- loopBundleVariantChange: Triggered when a variant within a bundle is changed.
- loopPresetBundleUpdateQuantity: Triggered when the quantity of a preset bundle is updated.


Storefront events



Build your bundle events
loopItemAddToBundleSuccessEvent : Triggered when an item is added to the bundle on the bundle builder page.
loopByobAddToCartSuccessEvent : Triggered when a build your bundle is successfully added to the cart through the Loop bundle page

Preset bundle event
loopPresetAddToCartSuccessEvent : Triggered when a preset bundle is successfully added to the cart from its product details page

By integrating these JS events into your development strategy, you can enhance user interactions and tailor the customer experience in Loop's customer portal to better meet the needs of your audience.


Need help?



No need to fret; we’re here to jump in and help you out. Reach out to us at support@loopwork.co or feel free to ping us on chat by clicking the support beacon on the bottom right.

Thanks!

Loop Subscriptions Team 🙂

Updated on: 13/08/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!