Skip to main content
On Shopify, BigCommerce, Wix, Weebly and WordPress-rendered WooCommerce stores, the Privy code reads the visitor’s cart by itself. On a headless or custom storefront it can’t, so your storefront sends it with window.privyEvents. The cart value powers Cart Value display targeting and the cart value in your displays, such as a free-shipping bar. On a headless WooCommerce store, the cart’s items also power abandoned cart and abandoned checkout flows.
These events run in the visitor’s browser. They update the Privy code on the page, and on a WooCommerce store they also save the cart for abandoned cart flows. To send orders to Privy, use the Orders API from your server.

Quick start

The whole integration is three calls, shown in the Quick start example:
  1. Set up the queue once per page.
  2. identify when the shopper signs in or gives you their email.
  3. cart_updated whenever the cart changes, including when it’s emptied after a purchase.
Using an AI coding assistant? Give it the Markdown version of this page: help.privy.com/docs/api-reference/browser-events.md.
The sections below cover each call in detail.

Set up the queue

Add window.privyEvents = window.privyEvents || []; before your first push, anywhere on the page. You can push events before the Privy code has loaded. They wait in the queue and run in order once it loads.

Events

Cart events

Send one whenever the cart changes: an item added, removed or updated, or the cart emptied.
Send total: 0 when the cart is emptied, including after a purchase.
If your storefront uses the WooCommerce Store API, its cart response has these values in totals. Send total_items minus total_discount as total, and pass currency_code and currency_minor_unit as they are. Send total_discount as discount. Don’t use total_price, which includes shipping and tax.

Cart items (WooCommerce)

On a headless WooCommerce store, add the cart’s items and id to your cart events so Privy’s abandoned cart flows can email the cart.
Cart items are currently supported for WooCommerce stores only. Abandoned carts from Custom Integration storefronts aren’t currently supported, but those storefronts can still send cart totals for Cart Value targeting.
Items with missing or invalid ids or quantities are skipped. Privy reads product names, images and links from your store’s catalog, so don’t send them. The cart link in abandoned cart emails goes to your WordPress site’s address, so redirect it to your storefront.
Privy saves the cart as soon as identify or a signup on a Privy display tells it who the shopper is, and links it to their contact on their next page. Carts are saved only for stores connected to Privy through WooCommerce.

Identify

Tell Privy who the visitor is, for example when they sign in.

Things to know

  • Push when the cart changes, not on every render. In a framework like React, push from your cart’s change handler, not from a component that re-renders. Repeated pushes with the same total are throttled, but each one still does work in the browser.
  • Cart events are ignored on platforms Privy already reads. On the platforms listed at the top of this page, the Privy code reads the cart itself and ignores cart events from privyEvents. identify works everywhere.
  • checkout_started starts a checkout on WooCommerce. On a headless WooCommerce store, send it when the shopper reaches checkout, with the cart’s id and items (see Cart items), so abandoned checkout flows can email them. Elsewhere it only updates the cart.
  • Calling the WooCommerce Store API from another domain: if your storefront and WordPress are on different domains, WordPress only answers your storefront’s requests once its domain is allowed. Add it with WordPress’s allowed_http_origins filter.