Download the PHP package hirale/openmage-ga4-measurement without Composer

On this page you can find all versions of the php package hirale/openmage-ga4-measurement. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openmage-ga4-measurement

Hirale GAMeasurementProtocol

Server-side Google Analytics 4 events for OpenMage and Maho, delivered by a background queue worker over your choice of transport:

The transport is selectable per store view; observers and queued payloads are identical either way, so switching transports never loses in-flight events — each queued message is sent via the transport configured at the moment it is consumed.

This module can work with Mage_GoogleAnalytics module. For duplicate key events, you can consult this page https://support.google.com/analytics/answer/12313109?hl=en

Supported Events

You can check more events in the events section.

Queue backend

Events are never posted from the request that generated them: the observer hands a message to a queue and a worker uploads it. There is no shared queue package any more — the module picks a backend at runtime, in this order:

Platform Backend Package to install
Maho with the core Maho_Queue module \Maho\Queue\QueueManager none — it ships with the platform
OpenMage \Hirale\Queue\Bus hirale/queue ^3.0
Neither — events are not queued; the storefront is unaffected

Maho_Queue wins whenever it is present and enabled, even on a store that also has hirale/queue installed.

4.0.0 is a breaking change. hirale/queue moved from require to suggest — OpenMage installs that upgrade from 3.x must require it explicitly, or events stop being queued — and googleads/data-manager did the same, so stores on the Data Manager transport must require it too. The messages, transports, config paths and analytics queue name are unchanged.

Install

The default Measurement Protocol transport needs nothing beyond ext-curl. The Data Manager API transport needs one extra package — see Setup — Data Manager API.

Maho (26.5+, with core Maho_Queue):

composer dump-autoload is required: it compiles the #[\Maho\Config\MessageHandler] attribute into vendor/composer/maho_attributes.php. Without it the message has no registered handler, and the queue refuses to decode it.

OpenMage (20.17+, PHP 8.3+) — one-time tweaks first; details in the hirale/queue README:

Usage

Configuration lives in System > Configuration > Sales > Google API > GA4 Server-Side Events. Enable the module, pick the API Transport, and follow the matching setup below. The Measurement ID (G-XXXXXXX, from Admin > Data Streams > choose your stream) is needed by both transports.

Setup — Measurement Protocol (default)

  1. Generate an API SECRET in the Google Analytics UI: Admin > Data Streams > choose your stream > Measurement Protocol > Create.
  2. Enter the Measurement ID and API Secret, save. The secret is stored encrypted and shown obscured afterwards; installs upgrading from 4.0.0 or earlier have their existing secret encrypted in place by the upgrade script, across every scope.

Setup — Data Manager API

This transport is optional, so its client is not installed by default:

It uses the REST transport, so neither ext-grpc nor ext-protobuf is required. Without the package the module keeps working on the Measurement Protocol; switching a store to Data Manager is refused at save time, and any message already queued for it fails with the same composer require hint instead of retrying forever.

One-time Google-side setup (detailed in Google's guide):

  1. Create (or pick) a Google Cloud project and enable the Data Manager API in it.
  2. Create a service account in that project (no Cloud IAM roles needed for ingestion) and download a JSON key for it.
  3. In GA Admin, open the property's Access Management and add the service account's client_email as Editor.
  4. Note the numeric Property ID (Admin > Property Settings) — this is not the G- Measurement ID.

Then in the store admin:

  1. Set API Transport to Data Manager API (OAuth service account).
  2. Enter the Measurement ID, the GA4 Property ID, and paste the full JSON key file into Service Account Key (JSON). The key is validated at save time and stored encrypted.
  3. Click Validate Destination — it sends a validate-only test event with the values on screen (nothing is recorded in GA4) and reports the Google requestId on success.

Queues and worker pools

Messages ride the analytics queue on both platforms. On Maho, config.xml routes that queue to the catch-all slow pool, so a GA4 upload — one outbound HTTP call that can block on Google — never competes with the resident fast pool that carries order mail. A host can retarget it from its own config.xml or local.xml. On OpenMage the same queue name is declared under <hirale_queue><routing> and has to exist in that module's configuration.

Event reporting rules

Transport semantics

Debug

Enable debug mode in the system config (gated by System > Developer > Developer Client Restrictions). Both transports log to the same file; Data Manager entries include the Google-assigned requestId.

Upgrading

From 3.x — Maho: nothing to do beyond composer dump-autoload; hirale/queue can be removed. OpenMage: add hirale/queue to your own composer.json, since this package no longer requires it. Both platforms: if any store uses the Data Manager API transport, add googleads/data-manager explicitly — it is no longer a hard requirement of this package, so an upgrade drops it.

From 2.x — no config action needed: the transport defaults to Measurement Protocol and the existing measurement_id/api_secret config keeps working unchanged. The 2.x branch remains the MP-only maintenance line.

License

The Open Software License v. 3.0 (OSL-3.0). Please see License File for more information.


All versions of openmage-ga4-measurement with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-mbstring Version *
jaybizzle/crawler-detect Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hirale/openmage-ga4-measurement contains the following files

Loading the files please wait ...