=== Opinly Analytics ===
Contributors: opinlyai
Tags: analytics, woocommerce, attribution, revenue, conversions
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

First-party visitor analytics and conversion attribution. Connect with one key — no snippet, no theme editing.

== Description ==

Opinly Analytics installs the Opinly tracker on your WordPress site and reports your conversions
back to Opinly, attributed to the marketing source that drove each one. The goal is one clear
number: which sources actually drive results.

A conversion can be:

* **A purchase** — on WooCommerce stores, every completed order is reported with its total.
* **A form submission** — on any site, with or without WooCommerce, form submissions are tracked
  and can be turned into valued conversions (for example a contact or signup form) in your Opinly
  dashboard. This is ideal for lead-generation and service sites that don't sell online.

Setup is one step: paste the Connect Key from your Opinly dashboard
(Analytics → Setup) into Settings → Opinly Analytics. The plugin then configures itself — no
snippet, no theme editing.

WooCommerce is not required — without a store you still get visit, click, form and source
tracking, plus form-submission conversions. Adding a store later turns on order revenue
automatically.

= How it works =

* The Opinly tracker is **bundled with the plugin** and enqueued the normal WordPress way. No code
  is loaded from a remote server — only anonymous analytics data is sent to the Opinly API.
* On the WooCommerce order-received page it fires a `purchase` event with the order total and the
  visitor's anonymous id (exact attribution).
* On order completion it also sends an HMAC-signed server-side webhook to Opinly as a reliable
  backstop. The two are de-duplicated by order id, so revenue is never double-counted.

= Privacy & consent =

* The tracker uses an anonymous, randomly-generated visitor id stored in the browser. It is consent
  aware: if a consent plugin compatible with the WordPress Consent API (or a cookie banner) is
  active, Opinly follows its decision for the "statistics" category.
* When a visitor submits a form containing an email address, that email is sent to Opinly to
  identify the visitor and attribute their conversion to the source that drove it. Aside from that
  email, **values typed into form fields are never captured** — only which fields a form has and
  that it was submitted.

== Installation ==

1. Install and activate the plugin.
2. In your Opinly dashboard, open Analytics → Setup → Connect WooCommerce and copy the Connect Key
   (it starts with `conn-`).
3. In WordPress, go to Settings → Opinly Analytics, paste the Connect Key, and click Connect.
4. That's it — the tracker is live, and on WooCommerce stores completed orders report to Opinly.

== Frequently Asked Questions ==

= Do I need a WooCommerce store? =

No. Without WooCommerce the plugin still tracks visits, clicks, forms and traffic sources, and your
form submissions can be set up as valued conversions in your Opinly dashboard — ideal for lead-gen
and service sites. If you add a WooCommerce store later, order revenue is reported automatically.

= Does this slow down checkout? =

No. The server-side order webhook is sent non-blocking, so it never delays the customer.

= Will it double-count an order? =

No. The client-side purchase event and the server-side webhook are de-duplicated by order id.

= Does it respect visitor consent? =

Yes. It registers with the WordPress Consent API and honors an active consent plugin's decision for
the "statistics" category. When no consent platform is present, a setting (on by default) controls
whether to track; you can turn it off.

== External services ==

This plugin connects to Opinly, a third-party analytics service operated by Opinly
(https://opinly.ai), to provide its analytics and revenue-attribution functionality. The plugin
will not function without an Opinly account and Connect Key.

What is sent, and when:

* **During setup:** when you save your Connect Key, the plugin calls the Opinly API
  (`https://api.opinly.ai/connect-info`) to exchange the key for your site's tracking
  configuration.
* **On each page view (from the visitor's browser):** an anonymous visitor id, the page URL,
  referrer, traffic-source parameters (UTM tags and ad click ids), and basic interaction events
  (clicks, form submissions). For form submissions only the field names are sent — never the
  values typed into them.
* **On a form submission containing an email (from the visitor's browser):** the submitted email
  address, used to identify the visitor and attribute their conversion.
* **On a WooCommerce purchase:** the order id, total, currency, and — server-side — the buyer's
  email address, used to attribute the sale to the visitor's earlier activity.

This data is transmitted to the Opinly API endpoint configured for your account.

* Terms of Service: https://opinly.ai/terms-of-service
* Privacy Policy: https://opinly.ai/privacy

== Privacy ==

Opinly receives an email address in two cases: when a visitor submits a form containing an email —
on any site, with or without WooCommerce — that email is sent to identify the visitor and attribute
their conversion; and on WooCommerce orders, the buyer's email is sent to attribute the sale. You
are the data controller for your visitors' and customers' data; Opinly acts as a data processor on
your behalf. Ensure your site's privacy policy discloses the use of Opinly and that you have an
appropriate lawful basis (and, where required, visitor consent) for analytics and attribution.

== Changelog ==

= 1.0.0 =
* Initial release: one-key connect, bundled tracker, and conversion attribution — WooCommerce
  order revenue (client + server, de-duplicated) plus form-submission conversions on any site,
  with consent-aware tracking.
