Skip to main content
Every save, remove and clear fires an event on window.loveful, wherever it happened: a product page button, a card heart, a wishlist card, or another tab. This guide uses them for a toast, a badge and analytics.

1. Wait for the bus

Your script may run before or after Loveful’s (loveful.js loads with defer). Check for the bus, and wait for loveful:ready when it isn’t there yet:
assets/wishlist-extras.js
Load your script from theme.liquid with defer:
layout/theme.liquid

2. Show a toast on save

Changes made in the shopper’s other tabs are relayed to this one, so check tab_id against loveful.tabId to react only to changes made here. A card heart’s snapshot can have an empty title: it’s filled from the product as it saves, and stays empty if that request fails. Loveful’s own translations are on the bus too. Use them for wording the merchant already set:

3. Update your own badge

For a count Loveful’s <loveful-count> can’t render, such as a number inside an SVG or a theme component, read state.size:
state holds the variant ids on the shopper’s default list. To mark something else as saved, such as a custom product card, use loveful.state.has(variantId) or loveful.productSaved(productId):

4. Send saves to your analytics

There are two ways in, depending on where your tracking runs.
Loveful publishes Shopify customer events, so a custom pixel (Settings > Customer events in Shopify admin) can subscribe to them like Shopify’s own:
Custom pixel
They’re published once, in the tab where the change was made, and respect the pixel’s customer privacy settings like any other event.
Loveful can also send wishlist events to the merchant’s GA4, Klaviyo, Meta and TikTok itself (Settings > Integrations). Don’t track the same save twice.

5. Track sharing

<loveful-share-link> dispatches bubbling DOM events when the shopper copies, resets or emails their link:

Server side

Storefront events only reach scripts on the page. To act on saves in your own systems (a CRM, a warehouse, Zapier), use webhooks: signed events for every signed-in shopper’s save, remove, share and wishlist purchase.