Download the PHP package freema/ga4-measurement-protocol-bundle without Composer
On this page you can find all versions of the php package freema/ga4-measurement-protocol-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download freema/ga4-measurement-protocol-bundle
More information about freema/ga4-measurement-protocol-bundle
Files in freema/ga4-measurement-protocol-bundle
Package ga4-measurement-protocol-bundle
Short Description Google Analytics 4 Measurement Protocol Bundle for Symfony applications
License MIT
Informations about the package ga4-measurement-protocol-bundle
Google Analytics 4 Measurement Protocol Bundle
This bundle provides a clean, object-oriented integration with Google Analytics 4 Measurement Protocol for Symfony applications. It uses an event-based approach to track page views, purchases, and custom events in GA4.
Requirements
- PHP 8.1 or higher
- Symfony 5.4 or 6.4, 7.1 +
Installation
Configuration
Add the bundle to your config/bundles.php
:
Create a configuration file config/packages/ga4_measurement_protocol.yaml
:
Full Configuration Reference
Using the Bundle
The bundle uses an event-based approach where you create specific event objects, add them to the client, and then send them. This makes the code cleaner and easier to understand.
Basic Usage
Page View Example
Purchase Event Example
Event Types
The bundle provides a variety of pre-defined event types that match GA4's standard events.
E-commerce Events
Engagement Events
Custom Event
Creating Your Own Event Classes
You can easily create your own event classes for specific events:
ID Management
Client ID
Client ID is required by GA4 to identify unique users. The bundle will:
- Try to get it from the
_ga
cookie -
Use a fixed value if configured:
-
Accept a programmatic value:
- Use a custom handler:
User ID
User ID helps identify logged-in users across devices. You can:
-
Set it programmatically:
- Use a custom handler:
Session ID
Session ID helps GA4 group events that happen in the same session. The bundle can:
-
Extract it from the GA4 cookie for your property:
-
Accept a programmatic value:
- Use a custom handler:
Debug Mode
Debug mode enables detailed validation of your events from GA4:
-
Configure it globally:
- Set it programmatically:
When debug mode is enabled:
- Events are sent to GA4's debug endpoint
- A
debug_mode
parameter is added to each event - More detailed validation messages are returned
License
This bundle is available under the MIT License. See the LICENSE file for more information.
All versions of ga4-measurement-protocol-bundle with dependencies
symfony/http-kernel Version ^5.4|^6.4|^7.1
symfony/framework-bundle Version ^5.4|^6.4|^7.1
symfony/dependency-injection Version ^5.4|^6.4|^7.1
symfony/config Version ^5.4|^6.4|^7.1
symfony/http-client Version ^5.4|^6.4|^7.1
symfony/yaml Version ^5.4|^6.4|^7.1
psr/http-client Version ^1.0
php-http/discovery Version ^1.14
symfony/http-client-contracts Version ^2.5|^3.0
nyholm/psr7 Version ^1.5