{"id":289074,"date":"2026-06-18T08:57:49","date_gmt":"2026-06-18T08:57:49","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/advanced-posthog-analytics\/"},"modified":"2026-06-18T19:07:22","modified_gmt":"2026-06-18T19:07:22","slug":"ag-data-for-posthog","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/ag-data-for-posthog\/","author":17209228,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.5.3","stable_tag":"1.5.3","tested":"7.0","requires":"5.8","requires_php":"7.4","requires_plugins":null,"header_name":"AG Data for PostHog","header_author":"AGStudio.ai","header_description":"PostHog Analytics for WooCommerce \u2014 server-side event tracking, marketing attribution engine, identity stitching, and LTV enrichment.","assets_banners_color":"fbfbfc","last_updated":"2026-06-18 19:07:22","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/alexgodlewski\/ag-data-for-posthog","header_author_uri":"https:\/\/github.com\/alexgodlewski","rating":0,"author_block_rating":0,"active_installs":0,"downloads":39,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.5.3":{"tag":"1.5.3","author":"levskipg","date":"2026-06-18 19:07:22"}},"upgrade_notice":{"1.4.0":"<p>Plugin renamed to AG Data for PostHog. All functionality and settings are preserved \u2014 no reconfiguration needed.<\/p>","1.3.1":"<p>Fixes identity stitching \u2014 form identify now fires on submit (not just blur), Order Completed events use email as distinct_id, and upsell orders are properly attributed.<\/p>","1.3.0":"<p>New element visibility tracking lets you know who actually saw key content on your landing pages \u2014 not just who triggered a pageview. Add <code>apha-track-view<\/code> class to any element.<\/p>","1.2.0":"<p>New form identification feature links anonymous visitors to PostHog profiles when they enter their email in any form. Works with all form builders and WooCommerce checkout flows.<\/p>","1.1.0":"<p>Major update: marketing attribution engine, identity stitching fix for PostHog funnels, LTV enrichment, and consent management. Recommended for all users.<\/p>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3577736,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3577736,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256},"icon.svg":{"filename":"icon.svg","revision":3577736,"resolution":false,"location":"assets","locale":false}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3577736,"resolution":"1544x500","location":"assets","locale":"","width":1544,"height":500},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3577736,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.5.3"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[232,9067,282,214764,286],"plugin_category":[36,45],"plugin_contributors":[267687],"plugin_business_model":[],"class_list":["post-289074","plugin","type-plugin","status-publish","hentry","plugin_tags-analytics","plugin_tags-attribution","plugin_tags-ecommerce","plugin_tags-posthog","plugin_tags-woocommerce","plugin_category-analytics","plugin_category-ecommerce","plugin_contributors-levskipg","plugin_committers-levskipg"],"banners":{"banner":"https:\/\/ps.w.org\/ag-data-for-posthog\/assets\/banner-772x250.png?rev=3577736","banner_2x":"https:\/\/ps.w.org\/ag-data-for-posthog\/assets\/banner-1544x500.png?rev=3577736","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/ag-data-for-posthog\/assets\/icon.svg?rev=3577736","icon":"https:\/\/ps.w.org\/ag-data-for-posthog\/assets\/icon.svg?rev=3577736","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>AG Data for PostHog connects your WooCommerce store to <a href=\"https:\/\/posthog.com\">PostHog<\/a> \u2014 the open-source product analytics platform. Track the complete customer journey from first click to lifetime value, all within PostHog.<\/p>\n\n<h4>Why AG Data?<\/h4>\n\n<p>Most WooCommerce analytics plugins give you pageviews and basic events. AG Data gives you a <strong>full marketing attribution engine<\/strong> \u2014 first-touch\/last-touch UTM tracking, ad click ID capture (Google, Meta, TikTok, Microsoft, LinkedIn), server-side first-party cookies that survive Safari ITP, and automatic LTV enrichment on every person profile.<\/p>\n\n<h4>Key Features<\/h4>\n\n<p><strong>Server-Side Event Tracking<\/strong><\/p>\n\n<ul>\n<li>Order Completed, Order Refunded, Order Status Changed<\/li>\n<li>Deduplication prevents double-counting<\/li>\n<li>Blocking API calls ensure delivery before marking as tracked<\/li>\n<li>Works with all payment gateways and checkout flows<\/li>\n<\/ul>\n\n<p><strong>Frontend Event Tracking<\/strong><\/p>\n\n<ul>\n<li>Product Viewed, Product List Viewed, Products Searched<\/li>\n<li>Product Added \/ Removed (classic and block-based carts)<\/li>\n<li>Cart Viewed, Checkout Started<\/li>\n<li>Product Clicked, Coupon Applied \/ Removed, Payment Info Entered<\/li>\n<li>Works without jQuery \u2014 block themes fully supported<\/li>\n<\/ul>\n\n<p><strong>Marketing Attribution Engine<\/strong><\/p>\n\n<ul>\n<li>Captures UTM parameters and ad click IDs (gclid, fbclid, ttclid, msclkid, li_fat_id)<\/li>\n<li>Server-side first-party cookies bypass Safari ITP 24-hour restriction<\/li>\n<li>First-touch and last-touch attribution persisted to every order<\/li>\n<li>Days-to-conversion and session count tracking<\/li>\n<li>Falls back to WooCommerce 8.5+ native attribution when cookies are unavailable<\/li>\n<li>Attribution data included in all PostHog order events<\/li>\n<\/ul>\n\n<p><strong>Identity Stitching<\/strong><\/p>\n\n<ul>\n<li>Reads PostHog JS SDK cookie server-side for seamless funnel connection<\/li>\n<li>Browser <code>posthog.identify()<\/code> for logged-in users<\/li>\n<li>Server-side <code>$identify<\/code> with <code>$anon_distinct_id<\/code> merges anonymous and known profiles<\/li>\n<li>PostHog funnels work end-to-end: Landing Page \u2192 Checkout Started \u2192 Order Completed<\/li>\n<\/ul>\n\n<p><strong>LTV Person Enrichment<\/strong><\/p>\n\n<ul>\n<li><code>total_orders<\/code>, <code>lifetime_value<\/code>, <code>avg_order_value<\/code>, <code>last_order_date<\/code> updated on every purchase<\/li>\n<li><code>first_order_date<\/code>, <code>acquisition_source<\/code>, <code>acquisition_medium<\/code>, <code>acquisition_campaign<\/code> set once via <code>$set_once<\/code><\/li>\n<li>Build PostHog cohorts like \"Customers with LTV &gt; $500 acquired from Google Ads\"<\/li>\n<\/ul>\n\n<p><strong>GDPR \/ Consent Management<\/strong><\/p>\n\n<ul>\n<li>Optional consent mode: starts PostHog opted-out with memory-only persistence<\/li>\n<li>Exposes <code>aphaOptIn()<\/code> \/ <code>aphaOptOut()<\/code> JavaScript functions<\/li>\n<li>Built-in support for CookieYes and Complianz consent management platforms<\/li>\n<\/ul>\n\n<p><strong>WooCommerce Compatibility<\/strong><\/p>\n\n<ul>\n<li>HPOS (High-Performance Order Storage) compatible<\/li>\n<li>Cart and Checkout Blocks compatible<\/li>\n<li>Classic and block checkout flows supported<\/li>\n<li>Reverse proxy support for first-party tracking domains<\/li>\n<\/ul>\n\n<h4>Requirements<\/h4>\n\n<ul>\n<li>WordPress 5.8+<\/li>\n<li>WooCommerce 7.0+<\/li>\n<li>PHP 7.4+<\/li>\n<li>A PostHog account (free tier available at posthog.com)<\/li>\n<\/ul>\n\n<h3>External services<\/h3>\n\n<p>This plugin connects to PostHog, a third-party product analytics service, to send your store's analytics and e-commerce event data. This connection is required for the plugin to work \u2014 its entire purpose is to record analytics in PostHog. No data is sent until you enter a PostHog Project API key in the plugin settings.<\/p>\n\n<p>What PostHog is used for:<\/p>\n\n<ul>\n<li>Receiving server-side e-commerce events (Order Completed, Order Refunded, Order Status Changed).<\/li>\n<li>Receiving frontend browsing events (Product Viewed, Cart Viewed, Checkout Started, and similar) via the PostHog JavaScript SDK, which is loaded on your site's pages from your configured PostHog host.<\/li>\n<li>Storing person profiles enriched with order\/LTV data and marketing attribution data.<\/li>\n<\/ul>\n\n<p>What data is sent, and when:<\/p>\n\n<ul>\n<li>While a visitor browses your store, the PostHog JavaScript SDK captures pageviews and browsing events. This includes page URLs, referrer, UTM parameters, ad click IDs (gclid, fbclid, ttclid, msclkid, li_fat_id), and a PostHog-generated anonymous identifier.<\/li>\n<li>When an order is placed, refunded, or changes status, the plugin sends order data from your server \u2014 order ID, totals, currency, line items, payment and shipping method, and billing\/shipping country. For logged-in users, a WordPress-based identifier and the customer email may also be sent so anonymous and known profiles can be merged.<\/li>\n<li>Requests are sent to the PostHog host you configure in the settings (PostHog US Cloud, PostHog EU Cloud, or your own self-hosted\/proxy URL).<\/li>\n<\/ul>\n\n<p>Service provider: PostHog Inc.\nTerms of Service: https:\/\/posthog.com\/terms\nPrivacy Policy: https:\/\/posthog.com\/privacy<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>ag-data-for-posthog<\/code> folder to <code>\/wp-content\/plugins\/<\/code><\/li>\n<li>Activate the plugin through the Plugins menu in WordPress<\/li>\n<li>Go to WooCommerce &gt; Settings &gt; AG Data<\/li>\n<li>Enter your PostHog project API key (starts with <code>phc_<\/code>)<\/li>\n<li>Select your PostHog region (US or EU)<\/li>\n<li>Optionally configure a reverse proxy URL for first-party tracking<\/li>\n<li>Done! Events will start flowing to PostHog immediately.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"where%20do%20i%20find%20my%20posthog%20api%20key%3F\"><h3>Where do I find my PostHog API key?<\/h3><\/dt>\n<dd><p>Log in to PostHog, go to Project Settings, and copy the Project API Key. It starts with <code>phc_<\/code>.<\/p><\/dd>\n<dt id=\"does%20ag%20data%20work%20with%20posthog%20cloud%20and%20self-hosted%3F\"><h3>Does AG Data work with PostHog Cloud and self-hosted?<\/h3><\/dt>\n<dd><p>Yes. Select US or EU for PostHog Cloud, or enter your self-hosted URL in the Custom Proxy URL field.<\/p><\/dd>\n<dt id=\"will%20this%20slow%20down%20my%20site%3F\"><h3>Will this slow down my site?<\/h3><\/dt>\n<dd><p>No. Server-side events use non-blocking HTTP calls. The frontend tracker is a lightweight script (~5KB) with no jQuery dependency. Attribution cookies are set server-side with minimal overhead.<\/p><\/dd>\n<dt id=\"does%20ag%20data%20work%20with%20safari%20itp%3F\"><h3>Does AG Data work with Safari ITP?<\/h3><\/dt>\n<dd><p>Yes. Unlike JavaScript-set cookies (which Safari caps at 24 hours for URLs with tracking parameters), AG Data uses server-side <code>setcookie()<\/code> calls. These are treated as first-party cookies and persist for the full configured duration.<\/p><\/dd>\n<dt id=\"how%20does%20attribution%20work%3F\"><h3>How does attribution work?<\/h3><\/dt>\n<dd><p>AG Data captures UTM parameters and ad click IDs (gclid, fbclid, ttclid, msclkid, li_fat_id) using server-side first-party cookies. First-touch and last-touch attribution data is persisted to every order and sent to PostHog, so you can analyze your full marketing funnel.<\/p><\/dd>\n<dt id=\"does%20ag%20data%20support%20woocommerce%20blocks%20checkout%3F\"><h3>Does AG Data support WooCommerce Blocks checkout?<\/h3><\/dt>\n<dd><p>Yes. Both classic (shortcode) and block-based checkout flows are fully supported for identity persistence and event tracking.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.5.3<\/h4>\n\n<ul>\n<li>Fix: Adds app_source=wordpress to server-side Order Completed attribution<\/li>\n<\/ul>\n\n<h4>1.5.2<\/h4>\n\n<ul>\n<li>Fix: Escapes PostHog JavaScript property names and $pageview in the inline bootstrap snippet<\/li>\n<\/ul>\n\n<h4>1.5.1<\/h4>\n\n<ul>\n<li>New: Adds a stable funnel_session_id across WordPress pageview, checkout, and server-side order events<\/li>\n<li>New: Adds funnel_key, host, source_host, source_page, and URL properties for cleaner PostHog CRO reporting<\/li>\n<li>Fix: Captures $pageview manually after registering funnel properties so landing-page views can join to checkout\/order events<\/li>\n<\/ul>\n\n<h4>1.4.0<\/h4>\n\n<ul>\n<li>Renamed plugin to AG Data for PostHog<\/li>\n<li>Fix: Inline scripts now use wp_add_inline_script() for WordPress standards compliance<\/li>\n<\/ul>\n\n<h4>1.3.1<\/h4>\n\n<ul>\n<li>Fix: Form identify race condition \u2014 added submit listener to catch email before Elementor\/AJAX redirect<\/li>\n<li>Fix: Autofill safety net \u2014 input listener catches browser autofill without blur<\/li>\n<li>Fix: Reduced form identify debounce from 400ms to 100ms<\/li>\n<li>Fix: Order Completed now fires identify before capture \u2014 events use email as distinct_id<\/li>\n<li>Fix: Upsell orders use billing email instead of random UUID fallback<\/li>\n<\/ul>\n\n<h4>1.3.0<\/h4>\n\n<ul>\n<li>New: Element visibility tracking \u2014 fire PostHog events when visitors see key page elements<\/li>\n<li>New: Add CSS class <code>apha-track-view<\/code> to any element (works with Elementor, Block Editor, raw HTML)<\/li>\n<li>New: Custom event names via <code>data-apha-event<\/code> attribute<\/li>\n<li>New: Custom visibility threshold via <code>data-apha-threshold<\/code> attribute (default 50%)<\/li>\n<li>New: IntersectionObserver-based \u2014 no scroll listeners, great performance<\/li>\n<li>New: MutationObserver catches lazy-loaded\/dynamic content<\/li>\n<li>New: \"Element Visibility Tracking\" toggle in WooCommerce &gt; Settings &gt; AG Data<\/li>\n<li>New: Consent-aware \u2014 re-initializes after opt-in when consent mode is active<\/li>\n<\/ul>\n\n<h4>1.2.0<\/h4>\n\n<ul>\n<li>New: Form identification \u2014 identifies anonymous visitors in PostHog when they enter an email in any form (checkout, contact, signup)<\/li>\n<li>New: Supports WooCommerce classic checkout, block checkout, and generic forms (Elementor, CF7, WPForms, plain HTML)<\/li>\n<li>New: Auto-detects email and name fields on blur \u2014 captures even abandoned forms<\/li>\n<li>New: \"Form Identification\" toggle in WooCommerce &gt; Settings &gt; AG Data<\/li>\n<li>New: Respects person_profiles mode \u2014 uses setPersonProperties (always) or identify (identified_only)<\/li>\n<li>New: Consent-aware \u2014 re-initializes after opt-in when consent mode is active<\/li>\n<\/ul>\n\n<h4>1.1.0<\/h4>\n\n<ul>\n<li>New: Marketing attribution engine with first-touch\/last-touch UTM tracking<\/li>\n<li>New: Ad click ID capture (Google, Meta, TikTok, Microsoft, LinkedIn)<\/li>\n<li>New: Server-side first-party cookies (bypasses Safari ITP)<\/li>\n<li>New: LTV person enrichment (total_orders, lifetime_value, avg_order_value)<\/li>\n<li>New: Identity stitching \u2014 reads PostHog JS cookie server-side for seamless funnels<\/li>\n<li>New: Browser posthog.identify() for logged-in users<\/li>\n<li>New: Product Clicked, Coupon Applied\/Removed, Payment Info Entered events<\/li>\n<li>New: Batch API endpoint support<\/li>\n<li>New: $set_once support for first_order_date, acquisition_source, created_at<\/li>\n<li>New: GDPR consent mode with CookieYes and Complianz integration<\/li>\n<li>New: WooCommerce 8.5+ native attribution fallback<\/li>\n<li>Fix: Race condition in Order Completed deduplication (TOCTOU)<\/li>\n<li>Fix: Replaced deprecated $create_alias with $identify + $anon_distinct_id<\/li>\n<li>Fix: Enabled capture_pageview for PostHog web analytics and session replay<\/li>\n<li>Fix: Standardized variant format (human-readable labels instead of IDs)<\/li>\n<li>Fix: jQuery dependency made optional for block themes<\/li>\n<li>Fix: False-positive product search detection<\/li>\n<li>Fix: Consolidated duplicate variation data loading (N+1 query)<\/li>\n<li>Improvement: Added payment_method, shipping_method, order_number, billing\/shipping_country to Order Completed<\/li>\n<li>Improvement: Refund deduplication prevents duplicate Order Refunded events<\/li>\n<li>Improvement: Max products filter for data layer safety valve<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release<\/li>\n<li>Server-side Order Completed, Order Refunded, Order Status Changed tracking<\/li>\n<li>Frontend Product Viewed, Product Added\/Removed, Cart Viewed, Checkout Started<\/li>\n<li>Product List Viewed and Products Searched<\/li>\n<li>PostHog JS SDK integration with reverse proxy support<\/li>\n<li>WooCommerce HPOS and Blocks compatibility<\/li>\n<li>Identity management with cookie-based distinct IDs<\/li>\n<\/ul>","raw_excerpt":"PostHog Analytics for WooCommerce. Server-side event tracking, marketing attribution engine, identity stitching, and LTV enrichment.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/289074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=289074"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/levskipg"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=289074"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=289074"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=289074"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=289074"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=289074"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=289074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}