=== Edgetally – Accurate Ecommerce Tracking for WooCommerce ===
Contributors: georget777
Tags: woocommerce, cloudflare zaraz, ga4, google ads, google tag manager
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

WooCommerce ecommerce tracking that runs on Cloudflare Zaraz, not on your server. Accurate GA4 events for Zaraz and Google Tag Manager.

== Description ==

**Tracking that does not slow your store down.**

Server-side tracking done from WordPress means your own server calls Meta, Google or TikTok for every product view, add to cart and purchase, and runs extra requests to do it. On a busy day, a sale or a newsletter send, that work lands on your server exactly when traffic peaks.

Edgetally moves that work to Cloudflare. The plugin hands each event to [Cloudflare Zaraz](https://www.cloudflare.com/application-services/products/zaraz/) in the visitor's browser, and Zaraz forwards it to your tools from Cloudflare's network:

* **No load on your server:** the plugin makes no outgoing requests, adds no database tables and runs no background jobs. Events are built from data WooCommerce has already loaded for the page.
* **Server-side delivery without your server:** Zaraz loads tools server-side, from Cloudflare. Meta receives events through the Conversions API (with your access token in Zaraz), without a single call from WordPress.
* **Fewer scripts in the browser:** instead of one script per pixel, your pages load one small Zaraz script, which helps page speed and Core Web Vitals.
* **Fully cacheable pages:** product, category and shop pages stay in your page cache and on Cloudflare's edge. Visitor-specific events never end up in cached HTML.
* **Available on every Cloudflare plan, including Free.** Your site needs to be proxied through Cloudflare.

Zaraz's e-commerce support covers Google Analytics 4, Meta (Facebook Pixel), TikTok, Bing, Pinterest and Amplitude. You turn on each tool once in the Zaraz dashboard and every event below reaches all of them.

**Google Ads included.** Zaraz's Google Ads tool has no e-commerce support, so the plugin also sends dedicated events for it (gads_purchase, gads_begin_checkout, gads_add_to_cart, gads_view_item) with value, currency, order ID and product IDs in Google's own parameter names. Add one Conversion action per event in Zaraz and Google Ads gets your conversions, without the Google Ads script on your pages.

Not on Cloudflare? The same events go to the Google Tag Manager dataLayer, with ready-made containers you can import: one for GA4, one for the Google Ads purchase conversion. You can use Zaraz and GTM at the same time.

= Accurate data =

The name is the promise: each event is sent once, with the right products and the right values.

* The full GA4 funnel: view_item_list, select_item, view_item, add_to_cart, remove_from_cart, view_cart, begin_checkout, add_shipping_info, add_payment_info, purchase and search
* Classic and block-based Cart & Checkout (Store API)
* AJAX add to cart without double counting; quantity changes count as add or remove for the difference only
* Purchase sent once, only on the buyer's own thank-you page (valid order key) and only for paid orders, never on a reload
* One spelling of product names everywhere (no "&amp;" vs "&" duplicates in your reports)
* Variations as parent ID + item_variant (or variation ID), brand, up to 5 category levels
* Free gifts and items inside bundles are not reported as products the shopper chose
* A search that finds a single product still counts (WooCommerce jumps straight to the product)
* Every event carries an event_id for deduplication
* Consent: with the WP Consent API option, no event is sent until the visitor has consented to the chosen category (works with consent plugins that support the WP Consent API, such as Complianz)

== External services ==

This plugin does not contact any external service from your server, and it never sends any data to the plugin author.

Nothing is sent anywhere after activation: every destination is off until the site owner turns it on in WooCommerce → Edgetally. When a destination is on, the store's own ecommerce events go to the site owner's own accounts:

* If you enable Cloudflare Zaraz, events are handed to Zaraz in the visitor's browser. Zaraz runs on your own Cloudflare account and forwards the data to the tools you configure there. Cloudflare's terms: https://www.cloudflare.com/website-terms/ and privacy policy: https://www.cloudflare.com/privacypolicy/
* If you enter a Google Tag Manager container ID, the standard GTM script is loaded from https://www.googletagmanager.com on your site's pages. Google's terms: https://marketingplatform.google.com/about/analytics/tag-manager/use-policy/ and privacy policy: https://policies.google.com/privacy

== Installation ==

1. Install and activate the plugin (WooCommerce is required).
2. Go to WooCommerce → Edgetally and choose the destinations.
3. Cloudflare Zaraz: in the Cloudflare dashboard, open Zaraz, add your tools (for example Google Analytics 4, Facebook Pixel, TikTok) and turn on "E-commerce tracking" for each of them.
4. Google Ads through Zaraz (optional): tick "Also send Google Ads events" in the plugin settings. In Zaraz, add the Google Ads tool with your Conversion ID, create a trigger "Event Name equals gads_purchase", and add a Conversion action on that trigger with your conversion label and these fields: value = {{ client.value }}, currency_code = {{ client.currency_code }}, oid = {{ client.oid }}. Repeat for gads_begin_checkout or gads_add_to_cart if you track them as conversions.
5. Google Tag Manager (optional): in GTM go to Admin → Import Container, choose gtm/edgetally-ga4-container.json from the plugin folder, pick "Merge" and "Rename conflicting tags, triggers and variables", put your GA4 Measurement ID in the variable "Edgetally - GA4 Measurement ID" and publish. For Google Ads, import gtm/edgetally-google-ads-container.json the same way and fill in "Edgetally - Google Ads Conversion ID" and "Edgetally - Google Ads Purchase Label". Or build your own tags: the event names are listed above and the data follows Google's GA4 ecommerce dataLayer format.

== Frequently Asked Questions ==

= Why Cloudflare Zaraz? =

Because the heavy part of tracking then runs on Cloudflare's network instead of your server and your visitors' browsers. Your server only renders the page it was going to render anyway; there are no outgoing calls to Meta, Google or TikTok from WordPress.

= Does Zaraz cost anything? =

Zaraz is available on all Cloudflare plans, including Free. According to Cloudflare, every account gets 1,000,000 Zaraz events per month free; beyond that, Zaraz Paid costs $5 per month for each additional million. Without Zaraz Paid, Zaraz stops for the rest of the month once the free events are used up. Check Cloudflare's Zaraz pricing page for current terms.

= How does Google Ads work with Zaraz? =

Zaraz's Google Ads tool does not read e-commerce events, so with the Google Ads option on, the plugin also calls zaraz.track() with gads_purchase, gads_begin_checkout, gads_add_to_cart and gads_view_item. Each carries value, currency_code, oid (purchase only), ecomm_prodid, ecomm_pagetype and ecomm_totalvalue. You decide in Zaraz which of them become conversions. The option is off by default because each of these events also counts towards your Zaraz event allowance.

= What about privacy and consent? =

The plugin is off by default: no destination is active until you enable one. It collects nothing for its author. The events describe store activity (products, cart, order value); the plugin adds no names, emails or phone numbers to them. If your visitors must consent before analytics or marketing tracking, set Consent to "WP Consent API" and choose the category: events then wait until the visitor consents. You remain responsible for your cookie banner and privacy policy.

= Do I need Cloudflare? =

For Zaraz, yes: your domain must be proxied through Cloudflare. Without Cloudflare, use the Google Tag Manager option.

= Does it work with page caching? =

Yes. Page events (product, list) contain no visitor data. Cart events are delivered through small uncached requests (WooCommerce's AJAX fragments, a wc-ajax endpoint that is called only after a cart action, the Store API).

= Which items are excluded? =

Items inside bundles/composites (the bundle carries the price) and free gifts added by gift plugins, when the options are enabled. Use the edgetally_skip_cart_item and edgetally_skip_order_item filters for other plugins.

= Can I change the data? =

Yes, with filters: edgetally_item (each product), edgetally_purchase_ecommerce and edgetally_purchase_event (the purchase), edgetally_order_is_paid (which orders count as paid), edgetally_list_name, edgetally_primary_category, edgetally_skip_cart_item_keys, edgetally_skip_order_item_meta, edgetally_is_shopper_add, edgetally_settings and edgetally_script_data.

== Changelog ==

= 0.1.0 =
* First version.
