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 or Shopify store, the cart’s items also power abandoned cart flows, and on WooCommerce abandoned checkout flows too. On a headless Shopify or WooCommerce store, product views power Browse Abandonment flows.
These events run in the visitor’s browser. They update the Privy code on the page. On a WooCommerce or Shopify store they also save the cart for abandoned cart flows, and on headless Shopify and WooCommerce the shopper’s product views for Browse Abandonment. 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:- Set up the queue once per page.
identifywhen the shopper signs in or gives you their email.cart_updatedwhenever the cart changes, including when it’s emptied after a purchase.
Set up the queue
Addwindow.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.
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 supported for WooCommerce stores, and for Shopify stores (see Cart items (Shopify)). 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. If every item is invalid, the event leaves the saved cart as it was. 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.Cart items (Shopify)
On a headless Shopify store (Hydrogen or a custom storefront on the Storefront API), Shopify doesn’t send Privy its cart events, so your storefront sends the cart’s items and id instead. Privy saves the cart for abandoned cart flows.
Items without both ids, or with an invalid quantity, are skipped. If every item is invalid, the event leaves the saved cart as it was. Privy reads product names and images from Shopify, so don’t send them.
For
total, send the Storefront API’s cost.subtotalAmount in minor units (1899.90 USD is 189990). It’s before tax and shipping, and before discount codes applied to the whole cart.
When the shopper checks out, send them to the cart’s checkoutUrl exactly as the Storefront API returns it. Without its key, Shopify starts the checkout from a new cart, without the shopper’s email. The cart link in abandoned cart emails opens Shopify’s checkout with the cart’s items. It goes through your store’s Online Store address, so while that is password protected, shoppers see the password page first.
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 Shopify.Product views
Send aproduct_viewed event on each product page so Privy can use the shopper’s product views for Browse Abandonment flows. Product views are supported on headless Shopify and WooCommerce stores (see below for the id format).
Push once per product page view, when the product page opens, not on every render or variant change.
On Shopify, send the price if your Browse Abandonment flows use the Min Price of Products Viewed filter. Views sent without a price don’t count toward that filter.
Shopify: send the Storefront API product’s
id, starting gid://shopify/Product/, as it’s returned; the number alone isn’t recorded for Shopify. Send the variant’s price in your store’s currency. Privy doesn’t convert prices, so a price fetched with @inContext for another country can make the Min Price of Products Viewed filter match the wrong products. It uses only the prices in the currency of the shopper’s latest priced view. On a store’s Online Store pages, Shopify sends Privy the product views itself.
WooCommerce: send the product’s numeric id, as a number or a string of digits, such as the id WooCommerce’s Store API returns. For a variable product, send the parent product’s id, not the variation’s. Leave out price: Privy reads prices from your WooCommerce catalog. On a WordPress-rendered store, the Privy code records product views by itself.
If Privy already knows the shopper, for example from an earlier signup, each view is sent as it happens. Otherwise Privy sends the session’s views once
identify or a signup on a Privy display tells it who the shopper is. After a full page load that isn’t a product page, they’re sent with the next product view.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 and product view events are ignored on platforms Privy already reads. On the platforms listed at the top of this page, including a Shopify store’s own Online Store pages, the Privy code reads the cart itself and ignores cart and
product_viewedevents fromprivyEvents. Of those, only Shopify Online Store pages and WordPress-rendered WooCommerce pages record product views by themselves.identifyworks everywhere. checkout_startedstarts 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_originsfilter.