# AnalyticsEasy Pro: Magento 2 GA4 Server-Side Ecommerce Tracking

> Send GA4, GTM, and Google Ads data server-side from Magento 2, with full ecommerce events and per-page data points that survive ad-blockers and cookie consent.

---

## Overview

AnalyticsEasy Pro delivers Magento 2 GA4 server-side ecommerce tracking alongside browser-side GTM and Google Ads integration. It pushes enhanced ecommerce events - product views, add-to-cart, checkout steps, purchases, refunds - via both a browser-side data layer and, optionally, the GA4 Measurement Protocol so that ad-blockers and browser restrictions can't swallow your data.

![AnalyticsEasy Pro configuration overview](images/overview.png)

This module helps you:

- Track every ecommerce touchpoint - from product view to purchase - in GA4 without writing custom code
- Send server-side events via Measurement Protocol so blocked or cookieless browsers still register conversions
- Feed accurate purchase data into Google Ads for bid optimisation and remarketing audiences
- Enrich every event with product brand, stock status, variants, customer group, and custom attributes
- Attribute conversions driven by other Moogento modules (SmartCategories boosts, HelloCustomer campaigns, GiftEasy gift cards, NotifyMe alerts) back to the right source in GA4

---

## When to use this

Use AnalyticsEasy Pro when you want to:

- Replace or upgrade a legacy Universal Analytics or basic GA4 setup with a full enhanced-ecommerce integration
- Capture purchases that browser-side JavaScript misses - ad-blockers, iOS Intelligent Tracking Prevention, or cookie-consent declines
- Track Google Ads conversions and remarketing audiences directly from Magento without a custom GTM container
- Send extra product detail (brand, variant, custom attributes) into GA4 item parameters for richer reporting
- Measure which Moogento promotional features - category boosts, gift cards, loyalty campaigns - are actually driving revenue

---

## Key capabilities

- **GA4 enhanced ecommerce** - tracks all standard GA4 ecommerce events client-side via the data layer
- **Measurement Protocol (server-side)** - sends selected events directly from Magento's server, bypassing browser limitations
- **GTM container export** - generates an importable JSON container with Tags, Triggers, and Variables pre-wired to your store's data layer
- **Google Ads conversions** - fires purchase conversion tags and optionally excludes zero-total orders
- **Google Ads remarketing** - adds the remarketing tag sitewide for audience building
- **Rich data points** - brand attribute, stock status, variant, customer User-ID, customer group, two custom product attributes
- **Moogento attribution tracking** - listens to `moo_core_convertible_event` and forwards campaign attribution from SmartCategories, HelloCustomer, GiftEasy, and NotifyMe to GA4
- **Validation mode** - validates Measurement Protocol payloads against Google's debug endpoint before going live

---

## Installation

AnalyticsEasy Pro installs via Composer, then activates with a license key from your Moogento.com account. The whole flow takes about 5 minutes.

### Step 1: Get your Composer keys from Moogento.com

1. Sign in at **https://www.moogento.com** and open **My Plugins** in your account menu.
2. Find **AnalyticsEasy Pro** in the list of plugins you own.
3. Generate (or reveal) the Composer access keys for that plugin - a **public key** and a **private key**.
4. **Add your install domain to the key.** Each Composer key is tied to a specific domain - if you're installing on `yourstore.com`, add `yourstore.com` to the key's allowed domains. The Composer download will be rejected on any other domain.

If you run staging and production on different domains, add both - separate keys per environment are fine too.

### Step 2: Install the module with Composer

From your Magento 2 root directory:

```
composer require moogento/module-analyticseasypro
```

When Composer asks for credentials, paste the **public key** as the username and the **private key** as the password. They'll be cached in `~/.composer/auth.json` for future runs.

### Step 3: Enable the module in Magento

```
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
```

If you run `php bin/magento module:status Moogento_Analyticseasypro` you should see it listed as enabled.

### Step 4: Add your license key in the Moogento admin

1. Still on **https://www.moogento.com > My Plugins**, copy the **license key** for AnalyticsEasy Pro (separate from the Composer keys you used above).
2. In your Magento admin, go to **Stores > Configuration > Moogento > Licenses**.
3. Find the row for **AnalyticsEasy Pro** and paste the license key.
4. Click **Save Config**, then run `php bin/magento cache:clean` once.

The license validates within a few seconds. You should see the module's status flip to active. If it stays inactive, double-check the domain on the license matches where you've installed - domain mismatch is the most common cause.

---

## Setup overview

Most setup happens in:

Stores > Configuration > Moogento > AnalyticsEasy Pro

You'll mainly work with:

- **General** - module enable/disable switch
- **GTM (Google Tag Manager)** - Account ID, Container IDs, head/body snippet, GTM container JSON export
- **GA4 (Google Analytics 4)** - Measurement ID, debug mode, Measurement Protocol settings, Data Points
- **Ads (Google Ads)** - Conversion tracking, Ads Tag Sitewide, Remarketing

---

## Common setups

### Connect Google Tag Manager and get a ready-to-import container

GTM is the recommended starting point. You configure your account IDs here and then export a container JSON that already has Tags, Triggers, and Variables wired to AnalyticsEasy Pro's data layer - no manual tag writing required.

#### How to set it up

1. Go to:
   Stores > Configuration > Moogento > AnalyticsEasy Pro > GTM (Google Tag Manager)

2. Set:
   - **GTM: Account ID** = your GTM account number (digits only, e.g. `1234567`)
   - **GTM: Container - GTM ID** = your container's GTM ID (format `GTM-XXXXXXX`)
   - **GTM: Container - ID** = the numeric container ID from the GTM URL (e.g. `987654321`)
   - **GTM: \<head\> code** = paste the `<head>` snippet from GTM > Install Google Tag Manager
   - **GTM: \<body\> code** = paste the `<body>` snippet from the same GTM install page

3. Save Config.

4. Click **Generate GTM Container JSON** (the action button in the same group). Download the JSON file and import it into GTM: GTM account admin > Container > Import Container. Choose **Merge** to preserve any tags you already have.

![GTM configuration group](images/config-googletagmanager.png)

#### Notes

- Save Config before generating the JSON - the generator reads from saved config, not the on-screen form.
- If you later enable Measurement Protocol, pause any overlapping purchase/checkout tags in GTM to avoid double-counting events.
- Set **Skip: Customer pages** = Yes to exclude account, login, and registration pages from GTM tracking.

---

### Enable GA4 server-side ecommerce tracking with Measurement Protocol

Browser-side GA4 tracking works out of the box once GTM is configured. Add Measurement Protocol if you need events to reach GA4 even when JavaScript is blocked.

#### How to set it up

1. Go to:
   Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 (Google Analytics 4)

2. Set:
   - **Google tag ID: Measurement ID** = your GA4 Measurement ID (format `G-XXXXXXXXXX`)

3. Expand **Measurement Protocol** and set:
   - **Enable** = Yes
   - **Secret Key** = paste your Measurement Protocol API secret (from GA4 Admin > Data streams > your stream > Measurement Protocol API secrets > Create)
   - **Events** = select the events you want sent server-side (at minimum: Purchase, Begin checkout, Add to cart)
   - **Enable: Track admin-created orders** = Yes if phone/admin orders should appear in GA4
   - **Track Moogento attribution events** = Yes (default) to forward SmartCategories, HelloCustomer, GiftEasy, and NotifyMe attribution to GA4

4. Save Config.

![GA4 configuration group](images/config-googleanalytics.png)

#### Notes

- Use **Enable: Measurement Protocol Validation mode** = Yes during initial testing. Payloads are validated by Google but **not recorded** in your GA4 property - disable this before going live.
- Check `var/log/moogento_analyticseasypro.log` for `[SendXxxEvent]` lines to confirm events are being dispatched.

---

### Track Google Ads conversions

Once you have a Conversion ID and Conversion Label from Google Ads, AnalyticsEasy Pro can fire the conversion tag on the order success page.

#### How to set it up

1. Go to:
   Stores > Configuration > Moogento > AnalyticsEasy Pro > Ads (Google Ads) > General

2. Set:
   - **Ads: Conversion ID** = your Google Ads Conversion ID (digits only, e.g. `1066481234`)
   - **Ads Tag Sitewide: Enable** = Yes

3. Go to:
   Stores > Configuration > Moogento > AnalyticsEasy Pro > Ads (Google Ads) > Conversions

4. Set:
   - **Conversions: Enable** = Yes
   - **Ads: Conversion label** = your Conversion Label code (e.g. `BKWdCOLgjIEaEPZsxQeP`)
   - **Ads: Conversion currency code** = your store's currency (default: `USD`)
   - **Ads: Skip conversion code for zero total orders** = Yes if you use free-order promotions and don't want them counted as conversions

5. Save Config.

![Google Ads configuration group](images/config-googleads.png)

---

## Features reference

### Data Points

Controls which product and customer attributes are included in every GA4 event. Richer item data unlocks more powerful GA4 exploration reports.

- **What it does:** Adds brand, stock status, variant, custom attributes, and customer identifier to each event's item parameters and user properties.
- **When to use it:** When your GA4 reports need segment breakdowns by brand, product variant, or customer group; when you run User-ID tracking across devices.
- **Config path:** Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 (Google Analytics 4) > Data Points (`moogento_analyticseasypro/googleanalytics/data_points`)

Key fields:

| Setting | Default | Notes |
|---|---|---|
| Track product: Identifier | Product ID | Switch to SKU if your reporting is SKU-based |
| Track product: Prices including tax | Yes | Match your displayed storefront pricing |
| Track product: Category | Child category | Use parent category for top-level funnel analysis |
| Track product: Brand | No | Enable and pick a product attribute to populate |
| Track product: Stock status | No | Useful for out-of-stock conversion analysis |
| Track product: Variant | No | Enable for configurable products |
| Track product: Custom attribute 1 & 2 | No | Map any product attribute to a GA4 item parameter |
| Track customer: User-ID | No | Sends customer ID for cross-device tracking |
| Track customer: Group | No | Sends customer group (Wholesale, Retail, etc.) |

![Data Points configuration group](images/config-data-points.png)

---

### Google Ads Remarketing

Adds a legacy remarketing tag for accounts that manage audiences through the Google Ads tag rather than GA4 audiences.

- **What it does:** Fires a remarketing conversion pixel on every page, allowing Google Ads to build audience lists from your store visitors.
- **When to use it:** Only needed if you have a legacy Ads account or were told to use the Google Ads tag for remarketing rather than GA4-based audiences.
- **Config path:** Stores > Configuration > Moogento > AnalyticsEasy Pro > Ads (Google Ads) > Remarketing (`moogento_analyticseasypro/googleads/remarketing`)

---

## Advanced configuration

### Measurement Protocol - Moogento attribution events

#### What it does

When **Track Moogento attribution events** is enabled, AnalyticsEasy Pro listens to the `moo_core_convertible_event` Magento event fired by other Moogento modules. Each time a sale is completed that was influenced by a Moogento feature - a SmartCategories boosted product, a HelloCustomer campaign click, a GiftEasy gift card, or a NotifyMe back-in-stock alert - the module sends a `campaign_details` GA4 event containing UTM parameters and the source module name.

#### Setup

1. Enable Measurement Protocol (see Common setups above - both the API secret and Enable toggle are required).
2. Go to Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 (Google Analytics 4) > Measurement Protocol.
3. Set **Track Moogento attribution events** = Yes (this is the default).
4. Save Config.

#### Notes

- This setting has no effect if Measurement Protocol is disabled or the API secret is blank - configure those first.
- Attribution events are sent in addition to the standard `purchase` event; they don't replace it.
- To view attribution in GA4, look for the `campaign_details` event in the Events report and filter by the `source` parameter.

---

### GA4 Debug mode

#### What it does

Enables the GA4 DebugView feature so events appear in real time in the GA4 Debug View interface (GA4 > Admin > DebugView). Useful for confirming that events and parameters are correct before launch.

#### Setup

1. Go to Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 (Google Analytics 4).
2. Set **Enable: GA4 Debug mode** = Yes.
3. Save Config and open GA4 Debug View in your browser.

#### Notes

- Debug mode sends extra signals in the data layer; disable it in production.
- For Measurement Protocol events, use **Validation mode** instead - it hits Google's debug endpoint and logs the validation response, but events are not recorded in GA4.

---

## Tips & best practices

- Select only the Measurement Protocol events you genuinely need - every server-side call adds latency to the originating request (purchase, checkout). Start with Purchase and expand if needed.
- Match your **Prices including tax** setting to what your storefront shows; a mismatch makes GA4 revenue figures confusing.
- Enable **Skip: Customer pages** in the GTM group to avoid GTM events firing on account, login, and registration pages - these generate noise in your event reports.
- After generating and importing the GTM container JSON, open GTM Preview mode and walk through a full purchase to confirm all tags fire correctly before publishing.
- When using Measurement Protocol alongside GTM, pause any GTM purchase/checkout tags that overlap - both will fire independently and double-count events. The GTM container JSON generator notes which tags to pause.
- For User-ID tracking, pick a stable identifier (Customer ID is the default). Email address changes if a customer updates it; Customer ID never changes.
- Add both your production and staging domains to the Composer key's allowed domains list so CI/CD deployments don't fail.

---

## Troubleshooting

### Events not appearing in GA4

Events fire client-side but don't reach GA4.

- **Cause:** The Measurement ID (`G-XXXXXXXXXX`) is missing or set to the wrong store view scope.
- **Check:** Go to Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 (Google Analytics 4) and confirm the Measurement ID field is populated for the correct scope (Store View / Website / Global).
- **Resolution:** Set the Measurement ID at the correct scope, save, and clear cache. Also confirm there are no Content Security Policy violations blocking `www.google-analytics.com` in your browser console.

---

### Measurement Protocol events not recording in GA4

Server-side events are dispatched (you can see log entries) but don't appear in GA4 reports.

- **Cause:** The API secret key is missing, expired, or the Measurement ID doesn't match the data stream the secret belongs to.
- **Check:** In GA4, go to Admin > Data streams > your stream > Measurement Protocol API secrets and confirm the secret is still valid. Check `var/log/moogento_analyticseasypro.log` for `[SendXxxEvent]` entries and any error responses from Google.
- **Resolution:** Regenerate the API secret in GA4, paste the new value into Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 > Measurement Protocol > Secret Key, save, and clear cache. Confirm Validation mode is Off - when Validation mode is On, events are tested but never recorded.

---

### Duplicate events in GA4

The same event (e.g. `purchase`) appears twice for every order.

- **Cause:** Both GTM client-side tags and Measurement Protocol are firing for the same event.
- **Check:** In GTM Preview mode, identify which tags fire on the order success page. Compare with the Events selected in Measurement Protocol config.
- **Resolution:** In your GTM container, pause or remove the tags that overlap with Measurement Protocol events. Alternatively, deselect those events from the Measurement Protocol Events multiselect (Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 > Measurement Protocol > Events).

---

### CSP blocks tracking scripts

Browser console shows Content Security Policy violations for GTM or GA4 domains.

- **Cause:** Magento's default CSP policy doesn't allow inline scripts or connections to Google's tracking endpoints.
- **Check:** Open browser devtools > Console and look for CSP violation messages referencing `www.googletagmanager.com`, `analytics.google.com`, or `www.google-analytics.com`.
- **Resolution:** Add the required domains to your CSP whitelist via `app/code/{YourVendor}/{YourModule}/etc/config.xml` or Magento's admin CSP settings. The module's own `config.xml` already allows these domains for the checkout success page.

---

### GTM container JSON export produces an empty file

Clicking Generate GTM Container JSON downloads an empty or partial file.

- **Cause:** The required GTM fields (Account ID, Container GTM ID, Container ID) were not saved before generating.
- **Check:** Open Stores > Configuration > Moogento > AnalyticsEasy Pro > GTM and confirm all three ID fields are populated and saved.
- **Resolution:** Fill in all three fields, click Save Config, then click Generate GTM Container JSON.

---

## FAQs

<!-- seo: FAQPage schema - the page converter should emit JSON-LD for this section -->

## How do I send GA4 events even when customers block cookies or use an ad-blocker?

Enable the Measurement Protocol in Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 > Measurement Protocol - it sends selected events directly from your Magento server to GA4, bypassing the browser entirely. You need a GA4 API secret from your data stream settings to activate it.

## Does AnalyticsEasy Pro work with Google Tag Manager?

Yes - AnalyticsEasy Pro integrates natively with GTM. Configure your GTM Account ID, Container GTM ID, and Container ID in the GTM group, then use the built-in JSON export to generate a ready-to-import GTM container with Tags, Triggers, and Variables already wired to your store's data layer.

## How do I track which products or categories are driving the most purchases?

Enable enhanced ecommerce tracking (on by default once the Measurement ID is set) and expand the Data Points group to add brand, category, and variant tracking. GA4's Monetisation > Ecommerce purchases report then shows per-item and per-category revenue automatically.

## Will I get double events if I use both GTM tags and Measurement Protocol?

Yes, if you leave overlapping GTM tags running alongside Measurement Protocol. After enabling Measurement Protocol for purchase and checkout events, pause those same events in your GTM container - the module's GTM JSON export notes which tags to pause when Measurement Protocol is active.

## How do I set up Google Ads conversion tracking?

Go to Stores > Configuration > Moogento > AnalyticsEasy Pro > Ads (Google Ads) > General, enter your Conversion ID, then go to Conversions, enable it, and paste your Conversion Label. See the [Connect Google Ads conversions](#track-google-ads-conversions) setup above for the full walkthrough.

## Does AnalyticsEasy Pro track conversions from other Moogento modules like SmartCategories or HelloCustomer?

Yes - when Measurement Protocol is enabled, the **Track Moogento attribution events** toggle (on by default) forwards `campaign_details` GA4 events whenever a SmartCategories boost, HelloCustomer campaign, GiftEasy gift card, or NotifyMe alert drives a sale. See [Advanced configuration - Moogento attribution events](#measurement-protocol--moogento-attribution-events) for details.

## What happens if I disable AnalyticsEasy Pro?

Disabling the module (setting Enable = No or using `php bin/magento module:disable`) stops all data layer pushes, GTM snippet injection, Measurement Protocol calls, and Google Ads tags. No tracking data will reach GA4 or Google Ads until the module is re-enabled.

## Is AnalyticsEasy Pro compatible with Hyvä, Luma, and Porto themes?

Yes. The module's frontend blocks are theme-agnostic and inject into standard Magento layout handles (`head.additional`, `after.body.start`). It works with Luma, Porto, and Hyvä without additional compatibility modules.

## How do I test Measurement Protocol events before going live?

Enable **Measurement Protocol Validation mode** (Stores > Configuration > Moogento > AnalyticsEasy Pro > GA4 > Measurement Protocol > Enable: Measurement Protocol Validation mode = Yes). Events are validated against Google's debug endpoint and logged, but they are not recorded in your GA4 property. Disable Validation mode before you go live.

## Which plan do I need for AnalyticsEasy Pro?

AnalyticsEasy Pro requires a valid Pro or Growth plan license from Moogento.com. The standard AnalyticsEasy module is the entry-level version. Visit **https://www.moogento.com** and check the pricing page for current plan details.

---

## Related guides

- [SmartCategories](../smartcategories) - category merchandising module that emits Moogento attribution events tracked by AnalyticsEasy Pro's Measurement Protocol integration

---

## Need help?

- moo@moogento.com
- Include:
  - Magento version
  - Module name
  - What you're trying to do
