- Can I install freema/ga4-measurement-protocol-bundle in a Laravel application?
- Not in any useful way. It is a Symfony bundle built around a Bundle class, a DI extension, a config tree for measurement_id and api_secret, and service definitions wired for symfony/framework-bundle, which Laravel does not ship or boot. You end up with a config file Laravel cannot consume and a service the container cannot resolve, and Composer may refuse the install or pull a parallel framework in. If you want server-side GA4 events in Laravel, bind br33f/php-ga4-mp in your own service provider instead and treat this bundle as a reference implementation.
- Which Laravel versions does this GA4 Measurement Protocol package support?
- There is no Laravel support matrix at all, because the package targets Symfony. Its 1.2.1 CI runs against PHP 8.1 through 8.5 and Symfony 5.4, 6.4, 7.4 and 8.x, with PHPStan and PHPUnit. Laravel compatibility would depend entirely on the underlying PSR-18 library, which is framework-agnostic, so verify the symfony/framework-bundle constraint before spending time on a spike.
- How do I send server-side GA4 events from Laravel without the Symfony bundle?
- Install br33f/php-ga4-mp and bind it as a singleton in a service provider, reading the measurement ID and API secret from config backed by environment variables. Add a thin internal adapter or facade that your code calls, plus a queueable job so GA4 latency never sits in the request path. That is roughly 100 to 200 lines of code for config, the singleton, the facade and the job, and it keeps the vendor library swappable.
- Why does my GA4 event silently never arrive from an API route or queue worker?
- This is exactly the bug fixed in 1.2.1: DefaultCustomUserIdHandler called Request::getSession(), which throws on stateless routes, so send() returned an error and the event was dropped without any signal. The patch is good, but it confirms the bundle assumes a sessionful Symfony request lifecycle, which is the opposite of where Laravel API and queue-worker events originate. In your own adapter, generate client_id and session_id from your own identifiers and log errors explicitly rather than assuming delivery.
- How do I configure the GA4 measurement ID and API secret in Laravel?
- In the bundle these are config tree keys named measurement_id and api_secret, which is one of the reasons it does not port cleanly. In Laravel put both in config/services.php behind env variables and pass them into your bound client instance. Treat api_secret as a bearer-equivalent secret sent in a query string: keep it in a secret manager and make sure it can be rotated without a redeploy.
- How can I test or debug GA4 Measurement Protocol events before going live?
- Measurement Protocol returns 204 when it accepts a request, not when it validates one, so a 204 does not mean the event was well-formed. Validate your payloads locally, and route staging traffic through the /debug/mp/collect endpoint and inspect the validationMessages in the response. Also assert in tests that your adapter surfaces errors instead of swallowing them, since silent drops are the known failure mode of this stack.
- Does server-side GA4 tracking bypass ad blockers, and what about consent and GDPR?
- Yes, sending events from PHP keeps tracking independent of ad blockers and client-side scripts, which is the main reason to use the Measurement Protocol for purchases, signups and API actions. The flip side is that these events also bypass client-side consent banners. Any user_id, user_data, email or UUID-shaped parameter needs a documented lawful basis and a hashing story before it ships.
- What is the difference between this bundle and br33f/php-ga4-mp?
- All the real capability lives in br33f/php-ga4-mp, a PSR-18 client for POST /mp/collect with event and parameter builders. This repository is a Symfony wrapper that configures that library for Symfony apps. For Laravel you should integrate the library directly and use the bundle only as documentation for how the client is meant to be configured.
- Is freema/ga4-measurement-protocol-bundle actively maintained and production ready?
- The maintenance signal is modest but real: 1.2.1 is a community-reported bug fix backed by a CI matrix across PHP 8.1 to 8.5 and several Symfony majors, plus PHPStan and PHPUnit 10.5. That said, it is a single maintainer project with one star and no dependents, and since 1.2.1 the distribution no longer ships tests, CI or dev files, so you cannot run upstream's suite against your pinned version. Treat it as sample code rather than an inherited SLA, fork it if you depend on it, and write your own tests.
- Should I queue GA4 events in Laravel, and does the Measurement Protocol guarantee delivery?
- Queue them. Dispatching a job keeps analytics latency and failures out of your request cycle, which matters for checkout and signup flows. There are no delivery guarantees on the GA4 side either: the endpoint returns 204 on accept, not on validation, and the 1.2.1 bug shows a client-side error can suppress the send entirely with no upstream signal, so add retries plus your own logging and monitoring.