Skip to content

Analytics (GA4 / GTM)

Analytics wires Magento into the Google measurement stack — GA4, Google Tag Manager and Google Ads — and does it properly for a headless store: the full GA4 ecommerce data layer is delivered over GraphQL, so an Astro storefront pushes exactly the right view_item, view_item_list, add_to_cart and purchase events without you hand-coding any of them. It also does server-side tracking with Consent Mode, fires Google Ads conversions, and gives you an in-admin sales dashboard.

Analytics dashboard

Magento

Open Source 2.4.9 GA (and later 2.4.x).

PHP

Tested on 8.4 and 8.5.

Headless

Complete GA4 data layer + config over GraphQL for Astro.

Privacy

Consent Mode defaults, hashed customer identifiers, per-IP rate limiting.

Headless data layer (the hard part, solved)

Section titled “Headless data layer (the hard part, solved)”

A headless storefront can’t use Magento’s page-rendered GTM snippet — it has to build the GA4 data layer itself. This module hands it over ready-made:

{ analyticsConfig {
gtm_container_id ga4_measurement_id enabled
enhanced_ecommerce cookie_consent_required consent_mode_default
google_ads { tag_id conversion_enabled conversion_send_to
remarketing_enabled remarketing_id } } }

The storefront injects the GTM/GA4/Ads tags from this — including a ready-to-use conversion_send_to (AW-XXXX/LABEL) for the purchase conversion.

A toggle per GA4 recommended event, so you send exactly what you want:

view_item · view_item_list · select_item · add_to_cart · remove_from_cart · view_cart · begin_checkout · add_shipping_info · add_payment_info · add_to_wishlist · purchase · refund · search · login · sign_up.

Server-side events

Forward events to GA4 via the Measurement Protocol (an API secret), so conversions are recorded even when ad-blockers or ITP strip the client-side tag. A cron also back-fills any missed purchases.

Consent Mode

Ship Google Consent Mode v2 defaults (granted/denied) so tags respect the visitor’s cookie choice from the first page view.

Google Ads

Fire purchase conversions and dynamic remarketing with the right send_to value, assembled for you from the conversion ID + label.

Privacy-safe

Customer identifiers are SHA-256 hashed, the public event endpoint is allow-listed to known GA4 events and rate-limited per IP, and order data is ownership-checked.

AgenticEcom → Analytics → Dashboard gives you a quick in-Magento read on sales performance — a revenue trend chart plus a per-day grid of orders, revenue, invoiced and refunded totals — so you don’t have to leave the admin for a top-line view.

Stores → Configuration → AgenticEcom · Sales, Customers & Marketing → Analytics & Tracking

Analytics configuration

GroupKey settings
GeneralEnable the module.
Google Analytics 4Measurement ID, and a per-event tracking toggle for every GA4 event; include tax in purchase value.
Google Tag ManagerEnable + container ID.
Product AttributesProduct identifier (SKU/ID), brand attribute, category tracking + depth.
Google AdsTag ID, conversion ID/label + enable, remarketing ID + enable.
PrivacyConsent Mode on/off and default state.
Server-SideEnable Measurement-Protocol forwarding, API secret, headless flag, track missing purchases, track admin orders.
How does a headless storefront get the right GA4 events?

It queries analyticsConfig to inject the tags and analyticsDataLayer(page_type, entity_id) per page — the module returns the complete GA4 event as data_layer_json, which the storefront pushes straight to window.dataLayer. No event mapping to maintain on the front end.

Can anyone query another customer’s order data?

No. analyticsOrderData requires a logged-in customer and verifies the order belongs to them, so the purchase payload is only ever returned to its owner.

Is the public tracking endpoint abusable?

It’s hardened: only a fixed allow-list of recognised GA4 event names is accepted, and it’s rate-limited per client IP — so it can’t be used to inject arbitrary events or flooded.

Does it respect cookie consent?

Yes — it ships Google Consent Mode defaults you control, so tags honour the visitor’s choice, and customer identifiers are hashed before they’re sent.

Will conversions still record if the client tag is blocked?

Enable server-side tracking and events are sent to GA4 via the Measurement Protocol from your server, with a cron that back-fills any purchases the client-side tag missed.