jeffersongoncalves/laravel-gtag
Laravel package for integrating Google tag (gtag.js) and Google Analytics 4 into your application, with simple configuration, Blade support, and helpers for tracking page views and custom events.
composer require and publish the package's config/views if it ships them (php artisan vendor:publish --tag=...). Most setups need nothing beyond the service provider auto-discovery.<script> tag — that class is where the v3.1.0 nonce logic lives.Vite::cspNonce($nonce), and confirm the emitted script tag now carries nonce="..." with no other code changes. Apps that never set a nonce see byte-identical output to v3.0.x.Vite::cspNonce() and your CSP header. With laravel-security-headers 2.1 the header side is just 'nonce-{nonce}' in script-src; the package side is now automatic.'unsafe-inline', don't stack it. Once the nonce is emitted you can tighten script-src to 'nonce-...' (optionally with 'strict-dynamic'). Leaving 'unsafe-inline' in place means the nonce adds nothing.@if blocks around the component — easier to audit against your CSP.assertSee('nonce="test-nonce"', false) on the response body and an assertion that your CSP header contains 'nonce-test-nonce'. A mismatch between the two is the most common regression.boot() can leak across requests. Generate it per request in middleware and reset it explicitly.'unsafe-inline' as soon as a nonce or hash is present. Audit onclick= attributes and inline <style>/style= before flipping the policy — they will start failing at the same moment the nonce starts working.'strict-dynamic' plus a trusted loader, or a different strategy for those.{{ }} (escaped) versus {!! !!} — escaping is correct here; the failure mode is manual string-building that mangles quotes.script-src allowlisting or 'strict-dynamic', so don't assume a clean console means the policy is complete.How can I help you explore Laravel packages today?