# WooCommerce Plugin

Install the official plugin to load the SDK and auto-track the WooCommerce commerce funnel, including revenue.

Install the official Otter plugin to load the SDK and automatically track your WooCommerce commerce funnel — including purchases with revenue — without touching your theme.

Shopify gives Otter a native pixel that reports completed orders with structured data. The WooCommerce plugin brings WooCommerce to the same level: it injects the Otter SDK in your site's `<head>` with anti-flicker, and tracks product views, searches, add-to-cart, checkout starts, and purchases for you. Order data (total, currency, line items) comes straight from WooCommerce in PHP — not scraped from the page — so your revenue numbers are exact.

Because the WooCommerce thank-you page is on your own domain, the visitor's first-party `optimo_uuid` cookie is available there, so each purchase is attributed to the variant that visitor saw. Revenue is deduplicated by order id, so a refreshed confirmation page never double-counts a sale.

## Installation

1. **Download the plugin.** On your project's installation page, open the WooCommerce guide and click **Download the WooCommerce plugin**.
2. **Upload and activate.** In WordPress admin go to **Plugins → Add New → Upload Plugin**, choose the zip, click **Install Now**, then **Activate**.
3. **Paste your API key.** Open **Settings → Otter A/B Testing**, paste your project API key, and save. The SDK starts loading immediately.
4. **Verify.** Place a test order if you can, then click **Verify Installation** on your Otter project page. You should see commerce events arrive.

## Events tracked automatically

| Event | Trigger |
| --- | --- |
| `ViewContent` | Product page viewed |
| `Search` | Search submitted |
| `AddToCart` | Product added to cart |
| `InitiateCheckout` | Checkout started |
| `Purchase` | Order completed (with revenue) |

Configure a goal against any of these event names to score it. To score revenue, add a Revenue goal with the event name `Purchase` — see the [Goals](https://www.otterab.com/docs/building-tests/goals) and [Revenue & Currency](https://www.otterab.com/docs/building-tests/revenue-and-currency) guides.

Under the hood, the plugin calls the SDK with the order data on the thank-you page — equivalent to:

```js
optimo.revenue({
  value: 129.0,
  currency: 'USD',
  order_id: '1042',
  quantity: 2,
})
```

> **WooCommerce tips**
>
> **Remove any old snippet.** The plugin injects the SDK for you. If you were loading Otter via a header plugin or theme edit, delete that so the SDK isn't loaded twice.
>
> **It works without WooCommerce too.** The SDK loads on any WordPress site for A/B testing; the commerce events switch on automatically when WooCommerce is active.
>
> **Toggles live in settings.** Anti-flicker, commerce events, and sending the customer email on purchase can each be turned off under Settings → Otter A/B Testing.

## Frequently asked questions

### What does the WooCommerce plugin do?

Two things. First, it installs the Otter SDK in your site's <head> with anti-flicker — exactly like pasting the snippet by hand, but managed for you. Second, it tracks your commerce funnel automatically: product views (ViewContent), searches (Search), add-to-cart (AddToCart), checkout starts (InitiateCheckout), and completed orders (Purchase) with their revenue. It brings WooCommerce up to the same automatic tracking you get from the native Shopify integration.

### How do I install it?

Download the plugin zip from your project's installation page (the Download the WooCommerce plugin button under the WooCommerce guide). In WordPress admin, go to Plugins → Add New → Upload Plugin, choose the zip, click Install Now, then Activate. Open Settings → Otter A/B Testing, paste your project API key, and save. That's the whole setup — no theme files to edit.

### Where do I find my API key?

In your Otter dashboard, open the project and go to the installation page. The 22-character key is shown there (and is pre-filled in the plugin's install steps). Paste it into Settings → Otter A/B Testing in WordPress.

### How is revenue attributed to a variant?

When a visitor lands on your store the SDK assigns them to a variant and stores a first-party optimo_uuid cookie. Because the WooCommerce thank-you page is on your own domain, that cookie is available there. On the order-received page the plugin fires a Purchase event carrying the order total, currency, and id, and Otter credits that revenue to the visitor's assigned variant. The order data comes straight from WooCommerce (PHP), not from scraping the page, so it's exact.

### Will a purchase be counted twice if the customer refreshes the thank-you page?

No. Each Purchase event includes the order id, which Otter uses as a deduplication key. Refreshing the confirmation page, bookmarking it, or coming back later won't double-count the sale.

### Does it work with High-Performance Order Storage (HPOS)?

Yes. The plugin uses the WooCommerce CRUD API for all order access and declares HPOS compatibility, so it works whether your store uses the classic post-based order storage or the newer high-performance order tables.

### Do I still need to paste the snippet or use a header plugin?

No. The plugin injects the SDK loader for you, so you don't need WPCode or any header/footer plugin alongside it. If you were previously using a manual snippet, remove it after activating the plugin to avoid loading the SDK twice.

### Can I turn off commerce event tracking or customer email?

Yes. Settings → Otter A/B Testing has toggles for anti-flicker, commerce-event tracking, and sending the customer email on purchase (used to identify visitors across devices). The email toggle is on by default and mirrors the Shopify integration; turn it off if you'd rather not pass the buyer's email.

### What if I can't install a plugin — is there a manual option?

Yes. The WooCommerce installation page has an advanced Prefer a manual install? section with the head snippet plus example helper code for firing AddToCart and Purchase events from your theme. The manual route is more fragile and you maintain it yourself, so the plugin is the recommended path.

### Does the plugin require WooCommerce, or does it work on any WordPress site?

The SDK loads on any WordPress site, so you can run A/B tests even without WooCommerce. The commerce events (product view, add-to-cart, checkout, purchase) activate automatically when WooCommerce is active. On a non-Woo WordPress site the plugin simply loads the SDK and the settings page notes that commerce tracking is idle.

---

Canonical page: https://www.otterab.com/docs/getting-started/woocommerce
