Analytics - Google
Google Analytics 4 for Laravel, in two independent surfaces: a client-side gtag.js snippet for Blade, React or Vue, and server-side GA4 Data API reporting components. Install the tracking half alone, or add the Google base package for dashboards.
v1.1.0
MIT License
★ 0
composer require artisanpack-ui/analytics-google
$ composer require artisanpack-ui/analytics-google
✓ AnalyticsGoogle facade auto-discovered
$ php artisan vendor:publish --tag=analytics-google-config
✓ config/analytics-google.php
@ga4Snippet → tracking in your layout head
What it does
Track, then report
One directive puts GA4 on the page. Add the Google base package and the same install gives you overview and top-content components backed by the Data API.
One-directive tracking
@ga4Snippet emits the standard gtag.js snippet — and emits nothing when no measurement ID is set, so it is safe in a shared layout.
Consent-gated by default
With the analytics parent installed it registers as the google-ga4 provider and defers page_view until the analytics consent category is granted.
GA overview component
Sessions, users, page views and average engagement time, plus a daily trend chart over any date range.
Top pages and events
Top pages by views and top events by count, with configurable range and row limit.
Livewire, React and Vue
Every surface ships three ways — the JS components talk to built-in HTTP endpoints you can disable for headless apps.
Graceful degradation
Without the base package, reporting throws a typed BaseNotInstalledException and components render an install prompt instead of breaking.
Get started
Install and configure
Set GA4_MEASUREMENT_ID for tracking and GA4_PROPERTY_ID for reporting, then drop @ga4Snippet into your layout head.
1 · Install
composer require artisanpack-ui/analytics-google
2 · Add the base for reporting
composer require artisanpack-ui/google
3 · Publish config
php artisan vendor:publish --tag=analytics-google-config
4 · Publish JS components (optional)
php artisan vendor:publish --tag=analytics-google-js
Requirements
What you need
| Requirement | Detail | |
|---|---|---|
| Tracking only | This package alone — set GA4_MEASUREMENT_ID | |
| Reporting | artisanpack-ui/google, a connected Google account and GA4_PROPERTY_ID | |
| Components | livewire/livewire, or the published React / Vue sources | |
| Dashboard widgets | artisanpack-ui/cms-framework (optional) — guarded by view_analytics | |
| The two surfaces are independent: install this package alone for the gtag snippet, or add the Google base package when you want Data API dashboards. | ||
Put GA4 to work with Analytics Google
A consent-aware gtag snippet and Data API reporting components in one package. Free and open source under the MIT license.
