# stape/gtm-server-side-magento-module

> Stape Conversion Tracking Magento Module

`composer require stape/gtm-server-side-magento-module`

Canonical URL: https://packagento.com/stape/gtm-server-side-magento-module

## At a glance

- **Vendor**: stape (https://packagento.com/stape.md)
- **Latest version**: 1.0.41 — released 2026-04-29
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/stape/gtm-server-side-magento-module and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require stape/gtm-server-side-magento-module:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Stape Conversion Tracking Magento Module

## README

If you have your store on Magento, [Stape's GTM Server Side extension for Magento 2](https://commercemarketplace.adobe.com/stape-gtm-server-side-magento-module.html) can simplify the process and open up the world of server-side tagging. 

### The list of e-commerce events:
- Collection view
- View Item
- Add to cart
- Begin checkout
- Add payment info
- Purchase

### User data:

- Email
- First name
- Last name
- Customer ID

### Useful links:
 
- https://stape.io/blog/server-side-gtm-extension-for-magento-2
- https://stape.io/blog/facebook-conversion-api-for-magento
- https://stape.io/blog/server-side-google-analytics-4-for-magento

## Changelog

v1.0.41
- added try/catch block for product collection;

v1.0.40
- fixed issue with refund webhook;

v1.0.39
- fixed exception thrown during config save with empty custom loader;

v1.0.38
- fixed HEREDOC error happening with html minify enabled in production mode;

v1.0.37
- added logic to generate GTM snippet via API;

v1.0.36
- added admin configuration option to control purchase webhook;
- added payment_type param for purchase webhook;
- added shipping_tier param for purchase webhook;

v1.0.35
- fixed PHP7.4 backward compatibility;
- fixed CSP issue on checkout;

v1.0.34
- improved SKU tracking

v1.0.33
- added cart state to datalayer events;
- extended cookies list;

v1.0.32
- datalayer event value param added;

v1.0.31
- renamed module in admin panel;
- added select_item event;
- added item_variant param to datalayer;

v1.0.30
- added module version header;

v1.0.29
- img-src CSP rule added;

v1.0.28
- added PHP 8.4 compatibility;
- fixed code style;

v1.0.27
- added option to enable/disable '_stape' suffix in Datalayer events;

v1.0.26
- removed unneeded CSP rules
- added option to configure collection size for datalayer

v1.0.24
- added caching of cookie domain when generating _sbp cookie
- Fixed issue with the overridden price formatter pattern
- Fixed billing address overwritten by shipping address issue

v1.0.23
- added logic to fetch add to cart info and send the event if only productIds array is available

v1.0.22
- fixed duplicate address creation for logged in customer on checkout

v1.0.21
- removed Stape analytics option as no longer needed

v1.0.20
- removed usage of md5 hash

v1.0.19
- Implemented custom GTM loader generation logic with prefix as well as container id

v1.0.18
- Fixed potential issue with sending multiple purchase webhook events.

v1.0.17
- Hyva theme compatibility added.

v1.0.16
- acl.xml added.

v1.0.15
- fixed logic to trim GTM- only when custom loader and custom domain are populated.

v1.0.14
- fixed xml layouts.
- changed class methods visibility from private to public.

v1.0.13
- fixed broken url generation logic.

v1.0.12
- added quote_id param to purchase event and webhook.

v1.0.11
- Update snippets with new param names and format.

v1.0.10
- Fixed item price for purchase_stape event to include tax.

v1.0.9
- Fixed issue with cookie being re-generated on every page load.

v1.0.2
- Fixed issue with main snippet not showing when cookie keeper enabled.

v1.0.1
- Set _sbp cookie logic added, unneeded functionality cleaned.

v1.0.0
- Main functionality implemented.

## Recent Versions

| Version | Released |
|---|---|
| 1.0.41 | 2026-04-29 |
| 1.0.40 | 2026-04-20 |
| 1.0.39 | 2026-04-16 |
| 1.0.38 | 2026-04-02 |
| 1.0.37 | 2026-02-09 |
| 1.0.36 | 2026-01-23 |
| 1.0.35 | 2026-01-15 |
| 1.0.34 | 2025-12-29 |
| 1.0.33 | 2025-12-11 |
| 1.0.32 | 2025-11-10 |

Showing 10 of 40 versions. Full release history on https://packagento.com/stape/gtm-server-side-magento-module.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| jeremykendall/php-domain-parser | ^6.0 |
| php | >=7.4.0 |

## Quality

Latest release (1.0.41) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 1 | 1 warning (ruleset: Magento2) |
| PHPMD | Warning | 27 | 27 rule violations (IfStatementAssignment:16, UnusedFormalParameter:8, MissingImport:2, UnusedLocalVariable:1) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 25 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 45 | 45 | – | – |
| 2.4.8 | – | 45 | 45 | – |
| 2.4.9 | – | – | 45 | 45 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["stape/gtm-server-side-magento-module"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

stape is a Magento 2 vendor on Packagento. See https://packagento.com/stape.md for their full catalogue.

