How does guest to login identity sync work?
When a shopper logs in, Wishlist Hero folds their anonymous wishlist into their account wishlist server side, and the storefront resyncs from the server. This reference documents the merge algorithm and the client sequence, so custom UIs stay correct across the login boundary.
The server merge
On the first wishlist call after login, the API reconciles the browser’s guest hash with the customer’s account:
- Look up the wishlist by
StoreCustomerId. - If the browser sent a different hash, fetch that guest wishlist.
- Merge items by the key
ProductId_variantId: union semantics, duplicates collapse and keep their original save details. - If the customer had no wishlist, the guest wishlist is adopted and rebound to the customer.
- The customer’s email and name are back-filled from Shopify when missing.
- The response flags
merged: trueso clients know a reconciliation happened.
The merge is idempotent: repeating it with the same inputs changes nothing.
The client sequence
The storefront loader drives the resync:
- On page load it reads the logged in customer ID from
window.ShopifyAnalytics.meta.page.customerId. - It compares the customer’s server wishlist with the browser’s local guest reference.
- On a difference it triggers the server merge, then clears stale local state and reloads items from the server.
- Your listeners fire in order:
wishlist-hero-customer-id, thenwishlist-hero-wishlist-updatedwith fresh server items (wishlist-hero-wishlist-items-from-server).
document.addEventListener("wishlist-hero-wishlist-items-from-server", () => {
renderList(window.WishListHero_SDK.GetWishListItems());
});
Listening to the server items event, rather than caching local items across login, is what keeps custom UIs honest: the guest snapshot is dead the moment a merge runs.
Custom build checklist
- Send the customer ID on identified calls: REST
CreateOrGetExisting/:storeCustomerIdor the SDK’s customer context, so the merge can find the account list - Re-render on
mergedsignals: anywishlist-hero-wishlist-updatedafter login means re-fetch, not patch - Do not persist the guest hash server side: it is a browser secret by design and is retired at merge
- Assume collapse of duplicates: two saves of one variant as guest and customer become one item
Edge cases
| Case | Result |
|---|---|
| Guest saves on phone, logs in on desktop | Merge runs on the desktop’s first wishlist call; phone items arrive |
| Shopper logs out | Account list stays on the account; the browser keeps a fresh guest reference for any new anonymous saves |
| Merge then immediate re-login on another device | Idempotent merge; the union is stable |
| App in login required mode | Guests never create lists; the merge path never runs |
The merchant facing explanation lives in Guest lists and merge.