=== AdMindra Tracking for WooCommerce ===
Contributors: viktorgrahn
Tags: analytics, woocommerce, tracking, conversion-tracking, advertising
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.4.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects AdMindra tracking with WordPress, optional WooCommerce conversion events, and optional AdMindra AI personalization for selected page text.

== Description ==

AdMindra Tracking for WooCommerce connects your WordPress site to the AdMindra tracking service.

The plugin can install the AdMindra universal tracking script and, when WooCommerce is active, send common conversion events such as product views, add to cart, checkout starts and purchases.

Tracking is disabled by default. A site administrator must add an AdMindra Project ID, enable tracking and confirm the external service consent before any tracking script is printed on the frontend.

= Supported events =

* PageView
* ViewContent, when viewing a WooCommerce product
* AddToCart, when a product is added to the cart
* ViewCart, when viewing the WooCommerce cart
* BeginCheckout, when viewing checkout
* Purchase, when viewing the WooCommerce order received page

WooCommerce is optional. If WooCommerce is not active, the plugin can still send PageView events when tracking is enabled.

= Optional personalization =

The plugin can also load AdMindra AI Personalization when enabled by the site administrator. Personalization is disabled by default.

When enabled, AdMindra can adapt selected headline, supporting text and CTA elements based on traffic source, campaign parameters, language and page context. The plugin only changes elements selected in the settings, for example:

`[data-admindra-personalize="headline"]`
`[data-admindra-personalize="subheadline"]`
`[data-admindra-personalize="cta"]`

This feature is intended to improve relevance without using sensitive personal data or rewriting the whole page.

= External service =

This plugin connects to the AdMindra tracking service at:

https://admindra.com/api/tracking/event

If optional AdMindra AI Personalization is enabled, the plugin also connects to:

https://admindra.com/api/personalization/resolve

The tracking service is used to collect page and conversion events for advertising and campaign measurement inside AdMindra. The personalization service is used to retrieve text variants for selected page elements.

Service provider: AdMindra
Website: https://admindra.com/
Privacy Policy: https://admindra.com/privacy/
Terms: https://admindra.com/terms/

= Privacy =

When tracking is enabled by the site administrator, this plugin may send the following data to the AdMindra tracking endpoint:

* Event name, such as PageView, ViewContent, AddToCart, BeginCheckout or Purchase
* AdMindra Project ID
* Current page URL
* Referrer URL
* Page title
* Timestamp
* Event data related to the event

When personalization is enabled, the plugin may send the current URL, referrer URL, browser language, traffic source signals and page context to retrieve text variants.

When WooCommerce event tracking is enabled, the plugin may also send product, cart, checkout and purchase event data such as:

* Product IDs
* Product names
* SKU values
* Product categories
* Quantities
* Cart/order totals
* Currency
* Coupons
* Payment method identifier
* Order identifiers for conversion deduplication

The plugin does not intentionally send customer names, email addresses, phone numbers, billing addresses or shipping addresses.

Depending on your jurisdiction and consent setup, using this plugin may require updating your site privacy policy and obtaining consent before tracking.

= Debugging =

When debug mode is enabled in the plugin settings, the browser console exposes:

`window.AdMindraTrackDebug`

You can also add `?admindra_debug=1` to a frontend URL to temporarily inspect tracking payloads and transport status.

= Credits =

AdMindra is developed by Viktor Grahn / 3on Creative & Growth.

https://admindra.com/
https://3on.se/

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/admindra-tracking-for-woocommerce/` directory, or install the plugin through the WordPress Plugins screen.
2. Activate the plugin through the Plugins screen in WordPress.
3. Go to Settings > AdMindra Tracking.
4. Paste your AdMindra Project ID.
5. Confirm the external service consent.
6. Enable tracking.
7. Optional: enable AdMindra AI Personalization and choose the headline, subheadline and CTA selectors that may be changed.
8. Save settings.

== Frequently Asked Questions ==

= Does tracking start automatically after activation? =

No. Tracking is disabled by default. A site administrator must add a valid AdMindra Project ID, confirm external service consent and enable tracking.

= Is WooCommerce required? =

No. WooCommerce is optional. Without WooCommerce, the plugin can still send PageView events when tracking is enabled.

= Which WooCommerce events are supported? =

The plugin supports ViewContent, AddToCart, ViewCart, BeginCheckout and Purchase.

= How does personalization work? =

Personalization is disabled by default. When enabled, the plugin asks AdMindra for text variants and applies them only to selected elements, such as a marked hero headline, subheadline or CTA. It does not rewrite the whole page.

= Does the plugin send customer personal data? =

The plugin does not intentionally send customer names, email addresses, phone numbers, billing addresses or shipping addresses. WooCommerce purchase events may include order identifiers, totals, currency, coupons, payment method identifier and purchased product data for conversion measurement and deduplication.

= Can I test if tracking works? =

Yes. Enable debug mode in Settings > AdMindra Tracking, open the frontend, then check your browser console for `window.AdMindraTrackDebug`.

== Screenshots ==

1. AdMindra tracking settings page.
2. External service consent and Project ID configuration.
3. Debug mode with browser console testing.

== Changelog ==

= 1.4.2 =
* Security: the order-received page now verifies the WooCommerce order key before reading an order. Without it, visiting /checkout/order-received/<id>/ with no key printed that order's total, tax, shipping, payment method, coupons and line items into the page source, and order ids are sequential.
* Fixed: the Project ID check required a strict UUID, which silently disabled tracking for the many AdMindra project ids that are not one. It now accepts any safe label.
* Fixed: a purchase is counted once per order, recorded on the order itself. The previous guard was browser localStorage, so a cleared cache or a private window counted the same purchase again.
* Fixed: translations were declared with a class constant, which WordPress's translation tools cannot read, so no string was ever extracted or served.
* Added: events carry source "wordpress-plugin", so a plugin install can be told apart from a pasted snippet.

= 1.4.1 =
* Added optional AdMindra AI Personalization for selected headline, subheadline and CTA text.
* Added personalization settings and privacy disclosure.
* Tracking remains disabled by default and personalization is disabled by default.


= 1.4.0 =
* WordPress.org-ready baseline.
* Tracking disabled by default.
* Empty Project ID by default.
* Added explicit external service consent setting.
* Added English admin UI.
* Added privacy policy suggested content.
* Added readme.txt, license.txt and uninstall.php.
* Improved settings sanitization and Project ID validation.
* Kept WooCommerce optional.
* Kept sendBeacon string transport to reduce CORS/preflight issues.

= 1.3.0 =
* Improved browser transport by using string-based sendBeacon and simple fetch fallback.
* Added debug payload return and debug object.

== Upgrade Notice ==

= 1.4.0 =
This version is prepared for WordPress.org review. New installations do not track until explicitly enabled with a Project ID and consent confirmation.
