Analytics - Google - v1.0.0
Ga4Provider
Two classes handle registration with the artisanpack-ui/analytics parent. Full narrative details: Analytics Parent Integration.
Ga4Provider
ArtisanPackUI\AnalyticsGoogle\Providers\Ga4Provider — the provider descriptor. Always instantiated whether or not the parent is installed; used by AnalyticsGoogle::provider().
Constructor
public function __construct(
protected ConfigRepository $config,
protected Gtag $gtag,
)
Methods
getName(): string— the provider name fromanalytics-google.provider_name(defaultgoogle-ga4).isEnabled(): bool— delegates toGtag::isConfigured()(measurement ID set and tracking enabled).trackerScript(): string— the<script>snippet fromGtag::render(), ready for the parent's@analyticsScriptsoutput.getConfig(): array{measurement_id: ?string, respect_consent: bool, options: array<string, mixed>}— the config snapshot the parent's dashboard status view renders.
Ga4AnalyticsProviderAdapter
ArtisanPackUI\AnalyticsGoogle\Providers\Ga4AnalyticsProviderAdapter implements the parent's \ArtisanPackUI\Analytics\Contracts\AnalyticsProviderInterface. Only autoloaded when the parent is installed — referencing its type without the parent would fatal.
Constructor
public function __construct(
protected Ga4Provider $ga4,
protected string $name,
)
Instantiated inside the parent's extend() callback in the service provider's booted hook.
Methods
getName(): string— the configured provider name ('google-ga4'by default).isEnabled(): bool— delegates toGa4Provider::isEnabled().getConfig(): array— delegates toGa4Provider::getConfig().trackerScript(): string— delegates toGa4Provider::trackerScript().trackPageView( PageViewData $data ): void— intentional no-op. Client-side gtag.js emits page views from the browser.trackEvent( EventData $data ): void— intentional no-op. Same reason.
For server-emitted GA4 events (Measurement Protocol), use the provider that ships with the analytics parent.