Framework Guides

WooCommerce

Install the Ours Privacy Web SDK on a WooCommerce store, including tracking add to cart and purchase events and the caching plugin gotcha.

Use this page to install the Ours Privacy Web SDK on a WooCommerce store.

WooCommerce runs on WordPress, so the install is the WordPress install. This page covers the ecommerce specifics on top of it.


Steps to Integrate Ours Privacy with WooCommerce

1. Install the Web SDK

Follow the WordPress guide to add the snippet to your site's head. Any method that reaches the WordPress head works, whether that is a head-and-footer plugin or your theme.

2. Verify page views

  1. Load a product page on your live store.
  2. Open the browser console to check for script errors.
  3. In your Ours Privacy account, check Recent Events to confirm page views are arriving.

Tracking Ecommerce Events

WooCommerce does not emit events to Ours Privacy on its own, so track the moments you care about with ours('track', ...).

Add to cart. WooCommerce fires a jQuery event when a product is added from a shop or product page:

jQuery(document.body).on('added_to_cart', function () {
  ours('track', 'Added To Cart');
});

Purchase. The order received page is the reliable place to record a completed order. Add a snippet to your thank-you page template that passes the order total:

ours('track', 'Purchase Complete', { value: 100 });

Read the real order values from WooCommerce rather than hard-coding them. Your developer can output them into the page from the order object.


Caching Plugins

Caching and optimization plugins are the most common cause of tracking that works in one place and not another. They can defer, combine, or strip inline scripts, and they can serve a cached checkout page that skips your tracking call.

If events stop arriving after you install a caching plugin:

  1. Exclude the Ours Privacy snippet from script combining and deferral.
  2. Exclude cart, checkout, and order received pages from page caching.

See Script conflicts for more on plugins that interfere with tracking scripts.


Next Steps

If you need further assistance, contact us at support@oursprivacy.com.

How is this guide?

On this page