# Acoustic Connect integration for WooCommerce

![Version](https://img.shields.io/badge/version-1.2.0-blue.svg)
![WordPress](https://img.shields.io/badge/WordPress-6.7+-green.svg)
![WooCommerce](https://img.shields.io/badge/WooCommerce-3.0+-purple.svg)
![PHP](https://img.shields.io/badge/PHP-7.4+-777BB4.svg)
![License](https://img.shields.io/badge/license-GPL--2.0+-red.svg)

Send your WooCommerce store's shopper activity to Acoustic Connect.

## Description

With this plugin you can:

- ✅ Track page views
- ✅ Track product views
- ✅ Capture search behavior
- ✅ Track add to cart and remove from cart events
- ✅ Track orders
- ✅ Identify customers (email, phone and customer ID) so Connect can match activity to a contact
- ✅ Send events directly from the shopper's browser to Acoustic Connect
- ✅ Track visitor sessions automatically

## Features

- **Configuration**: Two settings to start: App Key and Collector URL
- **Per-event control**: Turn each event type on or off
- **Classic and block checkout**: Works with the classic cart and checkout and with the WooCommerce Cart, Checkout and Mini-Cart blocks
- **Sent from the browser**: Events go from the shopper's browser to Acoustic Connect, not through your WordPress server
- **Debug Mode**: Logs each event to the browser console while you set up
- **One credential**: Only your App Key is needed; no API user or token
- **HPOS compatible**: Works with WooCommerce High-Performance Order Storage
- **Newsletter consent (optional)**: Adds a "Subscribe to our newsletter" checkbox to the classic and block checkout and saves the answer on the order

## Installation

### Method 1: Upload in WordPress admin

1. Download the plugin ZIP file (`acoustic-connect-woo-<version>.zip`)
2. Go to WordPress Admin → Plugins → Add New
3. Click "Upload Plugin"
4. Choose the ZIP file and click "Install Now"
5. Click "Activate Plugin"

### Method 2: Manual installation

1. Download and extract the ZIP file
2. Upload the `acoustic-connect-woo` folder to `/wp-content/plugins/`
3. Go to WordPress Admin → Plugins
4. Activate "Acoustic Connect integration for WooCommerce"

### Method 3: WP-CLI

```bash
wp plugin install acoustic-connect-woo-<version>.zip --activate
```

## Configuration

### Required settings

1. **Open the settings:**
    - WooCommerce → Settings → Acoustic Connect

2. **Turn on tracking:**
    - Check "Enable Tracking" (the App Key and Collector URL fields appear)

3. **Enter your details:**
    - **App Key**: Your App Key (Connect → Data Management → App Management)
    - **Collector URL**: Your Collector URL (for example, `https://lib-us-1.brilliantcollector.com/collector/collectorPost`). It must be an Acoustic Collector URL; the plugin won't save any other URL
    - Click "Save Changes"

Tracking starts once it's turned on and both the App Key and Collector URL are saved.

### Optional settings

**Event configuration:**
- Turn individual event types on or off (page views, product views, search, add to cart, remove from cart, orders)
- All events are on by default

**Newsletter consent:**
- Turn on **Show Consent Checkbox** to add a "Subscribe to our newsletter" checkbox to the checkout page (classic checkout, and the Checkout block on WooCommerce 7.5 or later, where it appears under "Additional information" or in the order summary)
- The answer is saved on the order as `_ac_wc_consent_newsletter` (`true` or `false`)
- A ticked box is sent to Acoustic Connect with the order signal and opts the contact in to email in all consent groups, even if they unsubscribed before. An unticked box changes nothing
- The consent is sent only when tracking and **Track Orders** are on: with Track Orders off, the answer is saved on the order but not sent
- If two shoppers order in the same browser session (for example on a shared computer), only the first opt-in is applied: Acoustic Connect skips consent it already received in that session
- Acoustic Connect can also read the answer from your order webhooks when that integration is enabled for your account
- Off by default

**Debug options:**
- Turn on Debug Mode to log each event to the browser console (data is also sent uncompressed)
- ⚠️ Turn Debug Mode off on a live store

## Tracked events

### 1. Page view
Sent each time a page loads.

**Data captured:**
- Page URL (without query string)
- Page category (the first part of the URL path, or `homepage`)

### 2. Product view
Sent when a shopper opens a product page.

**Data captured:**
- Product ID, name, SKU
- Price, regular price, discount
- Currency
- Categories
- Product page URL and image URL

### 3. Search
Sent when a search results page loads.

**Data captured:**
- Search term
- Number of results

### 4. Add to cart
Sent when a shopper adds a product to the cart.

**Data captured:**
- Product details
- Quantity
- Price
- Variation details (if applicable)

Adds made by cart plugins (for example Modern Cart), by add-to-cart links and by themes are tracked too.

With the Cart, Checkout and Mini-Cart blocks, only changes the shopper makes are tracked. Adds from block-based product buttons are tracked only on pages that also show a cart block (such as Mini-Cart), and need WooCommerce 9.8 or later.

### 5. Remove from cart
Sent when a shopper removes a product from the cart, or reduces a quantity in a Cart or Mini-Cart block.

**Data captured:**
- Product details
- Quantity removed
- Price

Quantity changes made with "Update cart" on the classic cart page aren't tracked.

### 6. Order
Sent when the order confirmation page loads, if WooCommerce shows the order to that visitor. Each order is sent once per browser: reloading the page doesn't send it again.

**Data captured:**
- Order ID, total, subtotal, tax, shipping, discount, currency
- Items purchased (product, variation, quantity, price, discount, category)
- Billing email and phone, and the customer ID of registered customers

## API request format

The plugin sends each event from the shopper's browser to your Collector URL. Connect calls these events behavior signals. Data is compressed unless Debug Mode is on.

## Troubleshooting

### Events aren't being sent

**Check your settings:**
- Check that your App Key is correct
- Check that the Collector URL is one of the Acoustic Collector URLs
- Check that "Enable Tracking" is on
- Check that the event type is on under Event Configuration

**Check the browser console:**
- Turn on Debug Mode
- Look for JavaScript errors
- Look for `[Acoustic Connect]` messages

**Check the browser's Network tab:**
- Look for requests the browser blocked (shown in red)
- Open a request to your Collector URL and check that its response is `{"code":0,...}` (Connect answers with status 200 even when it rejects a request)

### Events are missing data

**Check WooCommerce:**
- Check that WooCommerce is active and up to date
- Check that products have a name, price and category
- Add a product to the cart and confirm it appears

**Check for PHP errors:**
- Turn on WordPress debug mode
- Check the error logs
- Look for conflicts with other plugins

### Session problems

**Clear caches:**
- Clear the browser cache
- Clear your WordPress cache
- Ask shoppers to clear cookies for your store

**Check cookies:**
- Make sure the browser allows cookies for your store (Connect uses a cookie named `TLTSID`)

## Security

### Data privacy

- Customer email address, phone number and customer ID (registered customers) are sent so Connect can match activity to a contact. They come from the customer account, the checkout, login and registration forms, and the order
- Only the billing phone is used to identify a shopper, never the shipping phone (which can be a gift recipient's). It is sent only when it can be matched exactly: a North American number (converted to international format), or, when no country is known, a number already in international format
- Order data is only added to the order confirmation page when WooCommerce itself would show the order to that visitor
- When the newsletter checkbox is on, a ticked box is sent with the order as an email opt-in
- The plugin doesn't collect passwords or payment details
- Data goes from the shopper's browser to Acoustic Connect over HTTPS
- In the shopper's browser, the plugin stores:
    - the shopper's email and phone for the visit
    - events waiting to be sent
    - the IDs of add-to-cart events already reported, shared by all tabs (local storage), so no tab reports them twice
    - a note of orders already sent
    - a cookie after an add to cart (`acoustic_connect_cart_event`), removed once the add is reported and after 2 minutes at the latest
- On your WordPress server, the plugin keeps the 10 most recent add-to-cart events (product and quantity, no personal data) in the WooCommerce session so the browser can pick them up; they expire after 2 minutes
    - Connect's session cookie (`TLTSID`)

### Best practices

- Turn Debug Mode off on a live store
- Keep the plugin and WooCommerce up to date
- Review who has admin access to your store regularly

## Performance

### Impact on site

- **SDK**: Loaded from the Acoustic CDN as a script in the page footer
- **Server**: Events are sent from the browser, not through your WordPress server

### Optimization

- The Acoustic Connect SDK batches, sends and retries events
- Order events are sent immediately

## Updates

### Checking for updates

WordPress shows plugin updates in:
- WordPress Admin → Dashboard → Updates
- WordPress Admin → Plugins

### Changelog

See `readme.txt` for version history and changes.

## Tips

1. **Test on staging**: Test your setup on a staging site before going live
2. **Watch the first events**: Turn on Debug Mode while you set up
3. **Confirm in Connect**: Check your Acoustic Connect dashboard to confirm events arrive
4. **Recheck regularly**: Confirm from time to time that events are still being sent

## Support

### Documentation

- [Acoustic Connect documentation](https://developer.goacoustic.com/acoustic-connect/docs/connect-sdk-overview)
- [WooCommerce documentation](https://woocommerce.com/documentation/)

### Get help

1. Review the Troubleshooting section
2. Check the browser console for errors
3. Check that the Collector URL in your settings is one of the Acoustic URLs
4. Contact Acoustic Support with your store URL, plugin version and browser console output (with Debug Mode on)

## License

This plugin is licensed under GPL-2.0+.

## Requirements

- **WordPress**: 6.7 or higher
- **PHP**: 7.4 or higher
- **WooCommerce**: 3.0 or higher
- **Browser**: Modern browsers with JavaScript enabled

## Credits

Built and supported by Acoustic.

---

**Version**: 1.2.0
**Last Updated**: October 2026
**Author**: Acoustic

For more information, visit [https://acoustic.com](https://acoustic.com)
