=== Nelston Easy Conversion Tracking for Google & Meta Pixel ===
Contributors: farhadisok
Plugin URI: https://nelston.com/Plugins
Author: Farhad Ali
Author URI: https://www.upwork.com/freelancers/farhad66
Tags: google tag manager, gtm, ga4, google ads, meta pixel
Requires at least: 5.6
Tested up to: 7.0
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Easily setup conversion tracking for Google Ads, Google Tag Manager (GTM), GA4 eCommerce DataLayer, Meta (Facebook) Pixel, and TikTok Ads.

== Description ==

**Nelston Easy Conversion Tracking for Google & Meta Pixel** is the fast, turnkey Google Tag Manager (GTM) and multi-platform conversion tracking solution for WordPress and WooCommerce. Set up **Google Ads**, **Google Analytics GA4 eCommerce DataLayer**, **Meta (Facebook) Pixel**, **OpenAI Ads (ChatGPT Ads)**, **TikTok Ads**, **Microsoft Ads (Bing)**, **Pinterest Tag**, **Snapchat Pixel**, **Reddit Pixel**, **Twitter/X Ads**, **AdRoll**, **Criteo**, **Taboola**, **Outbrain**, **VWO**, **CrazyEgg**, **Triple Whale**, **Hyros**, **Microsoft Clarity**, and **Hotjar** — in minutes without touching theme code.

### 🚀 Key Benefits & Features

* **Turnkey Setup**: Simple configuration interface — enter your pixel/container IDs and you're ready to track.
* **OpenAI Ads Conversion Tracking**: Measure purchases and visitor conversions driven from OpenAI / ChatGPT ad campaigns.
* **Google Consent Mode v2**: Built-in support for Google Consent Mode v2 signals (`ad_storage`, `analytics_storage`, `ad_user_data`, `ad_personalization`) ensuring full GDPR and UK/US privacy compliance.
* **Order Duplication Prevention**: Prevents counting duplicate conversion triggers when customers refresh Thank You / Order Received pages.
* **Scroll Depth Tracking**: Automatically measures visitor scroll depth (25%, 50%, 75%, 90%) and triggers `gtm4wp.scrollDepth` events.
* **GA4 WooCommerce eCommerce DataLayer**:
  - Automatically compiles standard GA4 ecommerce events into `window.dataLayer`:
  - `view_item`: Single product page views with ID, title, price, category, currency.
  - `view_item_list`: Shop and category archives with item index positions.
  - `add_to_cart`: Track AJAX and standard add-to-cart button clicks.
  - `view_cart`: Cart page item list, quantities, and totals.
  - `begin_checkout`: Checkout page starting event.
  - `purchase`: Thank You / Order Received page with transaction ID, total, tax, shipping, and item breakdown.
* **Full Page & User Meta DataLayer**:
  - Page attributes: `pagePostType`, `pagePostTitle`, `pagePostID`, `pagePostDate`, `pageCategory`, `pageTags`, `pagePostAuthor`.
  - Visitor attributes: `visitorLoginState` (`logged-in` / `logged-out`), `visitorUserRole`, `visitorUserId`.
  - Search metrics: `siteSearchTerm`, `siteSearchResultsCount`.
* **Automated Frontend Click & Link Listeners**:
  - Outbound link clicks (`gtm4wp.outboundClick`)
  - File download link clicks (`gtm4wp.downloadClick`)
  - Telephone & Email link clicks (`gtm4wp.telephoneClick`, `gtm4wp.emailClick`)
  - Contact Form 7 submissions (`gtm4wp.contactForm7Submitted`)
* **Multi-Platform Ad & Analytics Pixels**:
  - **Google Ads**: Global Tag (`gtag.js`) with conversion labels, values, and WooCommerce Thank You page triggers.
  - **Meta (Facebook) Pixel**: Base `PageView` with Thank You page conversion tracking (`Lead` / `Purchase`).
  - **OpenAI Ads Pixel**: PageView and WooCommerce order attribution for ChatGPT ads (`openai-pixel.js`).
  - **TikTok Ads Pixel**: Asynchronous pixel loader (`events.js`).
  - **LinkedIn Insight Tag**: Partner ID tracking loader (`insight.min.js`).
  - **Microsoft Ads (Bing UET)**: Universal Event Tracking loader (`bat.js`).
  - **Pinterest Tag**: Pagevisit and checkout conversion tracking (`core.js`).
  - **Snapchat Pixel**: PageView and purchase tracking (`scevent.min.js`).
  - **Reddit Pixel**: PageVisit tracking (`pixel.js`).
  - **Twitter / X Pixel**: PageView event tracking (`uwt.js`).
  - **AdRoll Ads**: Roundtrip pixel integration (`roundtrip.js`).
  - **Criteo Ads**: Criteo OneTag tracking (`ld.js`).
  - **Taboola Ads**: Universal pixel loader (`tfa.js`).
  - **Outbrain Ads**: Outbrain pixel loader (`obtp.js`).
  - **VWO (Visual Website Optimizer)**: A/B testing tag loader (`j.php`).
  - **CrazyEgg Analytics**: Heatmap script loader (`script.crazyegg.com`).
  - **Triple Whale**: E-commerce attribution pixel (`triplevis.js`).
  - **Hyros**: Universal attribution tag loader (`universal-script.js`).
  - **Microsoft Clarity**: Session recordings & heatmaps integration (`clarity.ms`).
  - **Hotjar**: Behavioral heatmaps & recordings (`hotjar.js`).

== External Services ==

This plugin connects to external third-party services to deliver analytics and tracking functionalities:

1. **Google Tag Manager (`googletagmanager.com`)**:
   - **Purpose**: Dynamically loads your Google Tag Manager container snippet.
   - **Data Sent**: Browser metadata, page URL, referrer, and user DataLayer events.
   - **Timing**: Triggered on frontend pageviews when enabled.
   - **Terms & Privacy**: [Google Privacy Policy](https://policies.google.com/privacy)

2. **Google Ads & GA4 (`googletagmanager.com`)**:
   - **Purpose**: Initializes the Google Tag (`gtag.js`) and sends conversion tracking events.
   - **Data Sent**: Page URLs, conversion values, currency, conversion labels, and transaction IDs.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [Google Privacy Policy](https://policies.google.com/privacy)

3. **Meta (Facebook) Pixel (`connect.facebook.net` & `facebook.com`)**:
   - **Purpose**: Loads the Meta Pixel library (`fbevents.js`) for conversion measurement and remarketing.
   - **Data Sent**: Meta Pixel ID, page URLs, headers, PageView, and conversion events.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [Meta Privacy Policy](https://www.facebook.com/privacy/policy/)

4. **OpenAI Ads (`cdn.openai.com`)**:
   - **Purpose**: Loads the OpenAI Ads Pixel (`openai-pixel.js`) to measure conversion events from ChatGPT ad campaigns.
   - **Data Sent**: OpenAI Pixel ID, page URLs, device specs, and order conversion data.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [OpenAI Privacy Policy](https://openai.com/privacy/)

5. **TikTok Ads Pixel (`analytics.tiktok.com`)**:
   - **Purpose**: Loads the TikTok Pixel library (`events.js`) to track website visits.
   - **Data Sent**: TikTok Pixel ID, page URLs, device metadata, and pageview events.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [TikTok Privacy Policy](https://www.tiktok.com/legal/page/global/privacy-policy/en)

6. **LinkedIn Insight Tag (`snap.licdn.com`)**:
   - **Purpose**: Loads the LinkedIn Insight Tag script (`insight.min.js`) for campaign retargeting.
   - **Data Sent**: LinkedIn Partner ID, page URLs, IP address, device specs, and timestamp.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [LinkedIn Privacy Policy](https://www.linkedin.com/legal/privacy-policy)

7. **Microsoft Ads / Bing (`bat.bing.com`)**:
   - **Purpose**: Loads Microsoft Universal Event Tracking script (`bat.js`) for Bing Ads.
   - **Data Sent**: Microsoft UET Tag ID, page URLs, and conversion events.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [Microsoft Privacy Policy](https://privacy.microsoft.com/en-us/privacystatement)

8. **Pinterest Tag (`s.pinimg.com`)**:
   - **Purpose**: Loads Pinterest Tag library (`core.js`) for audience retargeting and conversions.
   - **Data Sent**: Pinterest Tag ID, page URLs, and order conversion data.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [Pinterest Privacy Policy](https://policy.pinterest.com/en/privacy-policy)

9. **Snapchat Pixel (`sc-static.net`)**:
   - **Purpose**: Loads Snapchat Pixel library (`scevent.min.js`) for ad campaign measurement.
   - **Data Sent**: Snapchat Pixel ID, page URLs, and purchase event values.
   - **Timing**: Loaded on frontend pageviews when enabled.
   - **Terms & Privacy**: [Snapchat Privacy Policy](https://snap.com/en-US/privacy/privacy-policy)

10. **Reddit Pixel (`redditstatic.com`)**:
     - **Purpose**: Loads Reddit Pixel library (`pixel.js`) for campaign attribution.
     - **Data Sent**: Reddit Pixel ID and PageVisit events.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Reddit Privacy Policy](https://www.redditinc.com/policies/privacy-policy)

11. **Twitter / X Pixel (`ads-twitter.com`)**:
     - **Purpose**: Loads Twitter / X Universal Website Tag (`uwt.js`) for ad tracking.
     - **Data Sent**: Twitter Pixel ID and PageView events.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [X Privacy Policy](https://x.com/en/privacy)

12. **AdRoll (`s.adroll.com`)**:
     - **Purpose**: Loads AdRoll roundtrip tracking code (`roundtrip.js`) for retargeting.
     - **Data Sent**: AdRoll Advertiser & Pixel ID, page URLs, and interactions.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [AdRoll Privacy Policy](https://www.nextroll.com/privacy)

13. **Criteo (`static.criteo.net`)**:
     - **Purpose**: Loads Criteo OneTag script (`ld.js`) for dynamic retargeting.
     - **Data Sent**: Criteo Account ID and transaction events.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Criteo Privacy Policy](https://www.criteo.com/privacy/)

14. **Taboola (`cdn.taboola.com`)**:
     - **Purpose**: Loads Taboola universal pixel (`tfa.js`) for content ad conversions.
     - **Data Sent**: Taboola Pixel ID and pageview notifications.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Taboola Privacy Policy](https://www.taboola.com/policies/privacy-policy)

15. **Outbrain (`amplify.outbrain.com`)**:
     - **Purpose**: Loads Outbrain pixel script (`obtp.js`) for content marketing attribution.
     - **Data Sent**: Outbrain Marketer ID and pageview events.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Outbrain Privacy Policy](https://www.outbrain.com/privacy/)

16. **Visual Website Optimizer - VWO (`dev.visualwebsiteoptimizer.com`)**:
     - **Purpose**: Loads VWO testing code (`j.php`) for A/B experiment tracking.
     - **Data Sent**: VWO Account ID and visitor experiment metrics.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [VWO Privacy Policy](https://vwo.com/privacy-policy/)

17. **CrazyEgg (`script.crazyegg.com`)**:
     - **Purpose**: Loads CrazyEgg heatmap tracking code for click visualization.
     - **Data Sent**: CrazyEgg Account ID, scroll, and click data.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [CrazyEgg Privacy Policy](https://www.crazyegg.com/privacy)

18. **Triple Whale (`triplevis.com`)**:
     - **Purpose**: Loads Triple Whale visitor journey script (`triplevis.js`) for attribution.
     - **Data Sent**: Triple Whale Store ID and visitor pageviews.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Triple Whale Privacy Policy](https://www.triplewhale.com/)

19. **Hyros (`hyros.com`)**:
     - **Purpose**: Loads Hyros universal tracking code (`universal-script.js`) for ad attribution.
     - **Data Sent**: Hyros API Subdomain and visitor funnel tags.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Hyros Privacy Policy](https://hyros.com/privacy-policy)

20. **Microsoft Clarity (`clarity.ms`)**:
     - **Purpose**: Loads Microsoft Clarity library for session recording and heatmap analysis.
     - **Data Sent**: Clarity Project ID, user clicks, mouse movements, and scroll data.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Microsoft Clarity Terms](https://clarity.microsoft.com/privacy)

21. **Hotjar (`static.hotjar.com`)**:
     - **Purpose**: Loads Hotjar tracking code for behavior heatmaps and user feedback.
     - **Data Sent**: Hotjar Site ID, browser metadata, user interactions, and page views.
     - **Timing**: Loaded on frontend pageviews when enabled.
     - **Terms & Privacy**: [Hotjar Privacy Policy](https://contentsquare.com/privacy-policy/)

== Installation ==

1. Upload the `nelston-easy-conversion-tracking-pixel` directory to `/wp-content/plugins/`.
2. Activate **Nelston Easy Conversion Tracking for Google & Meta Pixel** via the **Plugins** menu in WordPress.
3. Go to **Settings -> Nelston Conversion Tracking** in your WordPress admin menu.
4. Enter your tracking IDs and enable the modules you need.

== Frequently Asked Questions ==

= Is Nelston Easy Conversion Tracking compatible with WooCommerce? =
Yes! It features a built-in GA4 eCommerce DataLayer compiler for WooCommerce. It automatically pushes `view_item`, `view_item_list`, `add_to_cart`, `view_cart`, `begin_checkout`, and `purchase` events to Google Tag Manager and GA4.

= Does this plugin support Google Consent Mode v2? =
Yes! Nelston Easy Conversion Tracking includes built-in Google Consent Mode v2 signals (`ad_storage`, `analytics_storage`, `ad_user_data`, `ad_personalization`) ensuring full privacy compliance.

== Changelog ==

= 1.2.0 =
* Feature - Introduced full GA4 eCommerce DataLayer, Google Ads, Meta Pixel, OpenAI Ads (ChatGPT), TikTok, Bing, Pinterest, Snapchat, Reddit, Twitter, AdRoll, Criteo, Taboola, Outbrain, VWO, CrazyEgg, Triple Whale, Hyros, Microsoft Clarity & Hotjar conversion tracking.
* Feature - Added Google Consent Mode v2 support (`ad_storage`, `analytics_storage`, `ad_user_data`, `ad_personalization`).
* Feature - Added Order Duplication Prevention for WooCommerce purchase conversions.
* Feature - Added Scroll Depth Tracking (25%, 50%, 75%, 90%) with automated DataLayer event pushes.
* Performance - Refactored tracking script loaders to use native WordPress `wp_enqueue_script` and `wp_add_inline_script` APIs for non-blocking page load speeds.
* Security - Hardened input sanitization and eliminated direct script injection textareas in compliance with WordPress security best practices.
* Documentation - Updated `== External Services ==` disclosures with official canonical Privacy Policy URLs for all 20+ supported analytics and ad platforms.

= 1.1.0 =
* Feature - Introduced full GA4 eCommerce DataLayer support for WooCommerce (product views, cart, checkout, and purchase events).

= 1.0.0 =
* Initial public release.
