=== PixelMili Tracker ===
Contributors: pixelmili
Tags: server-side tracking, conversions api, meta pixel, tiktok, cash on delivery
Requires at least: 6.3
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.0.10
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Server-side tracking for WooCommerce: send every order to Meta, TikTok and Google without Google Tag Manager. COD orders counted once delivered.

== Description ==

PixelMili Tracker connects your WooCommerce store to [PixelMili](https://pixelmili.com), a server-side conversion tracking service built for stores in Bangladesh. Orders and shopping events are sent from your server to the Meta Conversions API, TikTok Events API, Google Ads, Google Analytics 4, Snapchat, Pinterest and LinkedIn — no Google Tag Manager container to set up.

**What the plugin does**

* Sends **Purchase** from your server when an order is placed or paid — no browser involved, so ad blockers can't drop it.
* Sends **AddToCart** from your server, and gives the PixelMili browser script exact product and cart data for **ViewContent** and **InitiateCheckout**.
* Each event is sent exactly once. If you use your Meta Pixel through the plugin, browser and server events share one event ID so Meta counts every sale once.
* **Cash on Delivery:** COD orders are flagged, so PixelMili can send the Purchase only once the order is delivered — when you mark it *Completed*, or automatically from Steadfast or Pathao. Cancelled and returned orders never reach Meta as sales. You choose the timing in your PixelMili dashboard.
* Attaches the shopper's Meta/TikTok/Google click IDs and cookies, IP address and browser to server events so ad platforms can match them to the right person.
* **Cookie Keeper:** keeps a first-party backup of click IDs that Safari deletes after 7 days, so returning iPhone buyers are still attributed to your ads.

**What you need**

* A PixelMili account — new stores get two months free. After that there is a free plan and paid plans, payable by bKash or Nagad. See [pricing](https://pixelmili.com/pricing).
* WooCommerce.

Setup guide: [PixelMili docs — WooCommerce](https://pixelmili.com/docs/woocommerce).

== External services ==

This plugin is the connector for the PixelMili service and does not work without it. It talks to the following services:

**PixelMili** (https://pixelmili.com) — receives your store's events and forwards them to the ad platforms you connect in your PixelMili dashboard.

* *When:* on page views, product views, checkout, add-to-cart and when an order is placed, paid, completed, cancelled or refunded — only while the plugin is enabled and a Tracking ID is set.
* *What is sent:* the event name, page URL and referrer, the shopper's IP address and browser user agent, PixelMili / Meta / TikTok / Google / LinkedIn / Snapchat / Pinterest cookie and click IDs, product and cart details (IDs, names, prices, quantities, currency), and for orders the order number, total, whether it is Cash on Delivery, and the billing email, phone, name, city and country. PixelMili hashes personal details (SHA-256) before sending them to any ad platform.
* The browser script (`t.js`) is loaded from your PixelMili tracking address (by default `track.pixelmili.com`, or your own tracking subdomain).
* [Terms of Use](https://pixelmili.com/terms) · [Privacy Policy](https://pixelmili.com/privacy)

**Meta Pixel** (only if you enter a Meta Pixel ID in the plugin settings) — the plugin loads Meta's pixel script from `connect.facebook.net`, which sends the same events from the shopper's browser to Meta.

* [Meta Terms](https://www.facebook.com/legal/terms) · [Meta Privacy Policy](https://www.facebook.com/privacy/policy/)

As the store owner you are responsible for telling your visitors about this tracking, and for asking for their consent where the law requires it.

== Installation ==

1. Install and activate the plugin (Plugins → Add New → search "PixelMili Tracker").
2. Sign up at [pixelmili.com](https://pixelmili.com), add your store's domain, and copy its Tracking ID (it starts with `pm_`).
3. Go to Settings → PixelMili, paste the Tracking ID and save.
4. In your PixelMili dashboard, connect Meta, TikTok, Google and the other platforms you advertise on.
5. Open a product page on your store — the PixelMili dashboard shows your first event within seconds.

== Frequently Asked Questions ==

= Do I need Google Tag Manager? =

No. The plugin and your PixelMili dashboard are all you need.

= I already have a Meta Pixel. Will Meta count my sales twice? =

Enter your Meta Pixel ID in the plugin settings and remove any other Meta Pixel code or plugin. The plugin then runs the pixel itself and gives browser and server events the same event ID, so Meta counts each sale once.

= How are Cash on Delivery orders handled? =

By default PixelMili sends a COD order's Purchase only once it is delivered — when you mark the order *Completed* in WooCommerce, or automatically when Steadfast or Pathao reports it delivered (connect them in your PixelMili dashboard). You can also choose to send it as soon as the order is placed, or both.

= Does it work with page caching? =

Yes. Server events are sent from WooCommerce hooks, and the data the browser script needs is static per page. Cookie Keeper only sets cookies when they change and marks those responses as not cacheable.

= Does it slow my store down? =

Server events are sent in the background without waiting for a response, and the browser script loads asynchronously.

== Changelog ==

= 1.0.10 =
* Confirm COD orders by phone? New setting "COD order confirmed when status becomes": pick the status you move an order to after the call, and its Purchase is sent right then instead of after delivery. Default stays Completed (delivery only).
* Marking a COD order Completed is now reported as a delivery, so the "Both" timing's DeliveredPurchase always means delivered.

= 1.0.9 =
* Product, checkout, Add to Cart and Purchase events now carry per-item details (product ID, quantity, unit price) — what Meta catalog and Advantage+ catalog ads match on.
* The unused Meta Access Token field is gone from the settings page, and any token saved there is deleted. Your token belongs only in your PixelMili dashboard.

= 1.0.8 =
* Server events now carry the shopper's IP address and browser (they previously carried your server's), and Purchases use the IP and browser WooCommerce recorded at checkout — even when the order is completed later from wp-admin or by a payment gateway callback. Better ad-platform matching.
* Scripts are now loaded the WordPress way (enqueued, inline data via `wp_print_inline_script_tag`); inputs are sanitized throughout.
* Requires WordPress 6.3 and PHP 7.4.

= 1.0.7 =
* Cash on Delivery: Purchase is flagged as COD at placement; Completed sends a confirmation, Cancelled / Refunded / Failed a cancellation, so PixelMili can count the sale only once it is delivered.

= 1.0.6 =
* Cookie Keeper: first-party backup of click IDs that Safari would otherwise delete after 7 days.

= 1.0.5 =
* Each event now has exactly one source (browser or server), so ad platforms never count an action twice. Optional Meta Pixel managed by the plugin, deduplicated with server events.

== Upgrade Notice ==

= 1.0.10 =
Send the COD Purchase when you confirm the order by phone, not only on delivery.

= 1.0.9 =
Per-item product details for Meta catalog ads; removes the unused Access Token field (and any saved token) from your WordPress database.

= 1.0.8 =
Server events now send the shopper's IP and browser instead of your server's — better match quality on Meta and TikTok.
