### Install Filament Gtag via Composer Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/README.md Install the Filament Gtag plugin via Composer. ```bash composer require jeffersongoncalves/filament-gtag ``` -------------------------------- ### Publish and Run Settings Migrations Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/README.md Publish and run the settings migrations required by the plugin. ```bash php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="migrations" php artisan vendor:publish --tag=gtag-settings-migrations php artisan migrate ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/README.md Run the plugin's test suite. ```bash composer test ``` -------------------------------- ### Disable Settings Page with settingsPage(false) Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/README.md Disable the settings page while keeping automatic script injection. ```php GtagPlugin::make() ->settingsPage(false), ``` -------------------------------- ### GtagPlugin Class Implementation Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/resources/boost/skills/filament-gtag-development/SKILL.md The GtagPlugin class implements the Filament Plugin contract, managing the registration of the settings page and providing access to the plugin instance. ```php namespace JeffersonGoncalves\Filament\Gtag; use Filament\Contracts\Plugin; use Filament\Panel; use JeffersonGoncalves\Filament\Gtag\Pages\ManageGtagSettings; class GtagPlugin implements Plugin { protected bool $hasSettingsPage = true; public static function make(): static { return app(static::class); } public static function get(): static { $plugin = filament(app(static::class)->getId()); return $plugin; } public function getId(): string { return 'filament-gtag'; } public function register(Panel $panel): void { if ($this->hasSettingsPage) { $panel->pages([ ManageGtagSettings::class, ]); } } public function boot(Panel $panel): void {} public function settingsPage(bool $condition = true): static { $this->hasSettingsPage = $condition; return $this; } } ``` -------------------------------- ### Register GtagPlugin in PanelProvider Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/README.md Register the GtagPlugin in your PanelProvider to add the Google Analytics Settings page and inject the tracking script. ```php use JeffersonGoncalves\Filament\Gtag\GtagPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ GtagPlugin::make(), ]); } ``` -------------------------------- ### ManageGtagSettings Page Configuration Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/resources/boost/skills/filament-gtag-development/SKILL.md The ManageGtagSettings class defines the form schema for the plugin's settings, including general tracking options and advanced configuration fields. ```php namespace JeffersonGoncalves\Filament\Gtag\Pages; use Filament\Forms\Components\KeyValue; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Pages\SettingsPage; use Filament\Schemas\Components\Section; use Filament\Schemas\Schema; use JeffersonGoncalves\Gtag\Settings\GtagSettings; class ManageGtagSettings extends SettingsPage { protected static string $settings = GtagSettings::class; protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chart-bar'; public function form(Schema $schema): Schema { return $schema ->columns(null) ->schema([ Section::make(__('filament-gtag::pages.sections.general.heading')) ->description(__('filament-gtag::pages.sections.general.description')) ->schema([ TextInput::make('gtag_id') ->label(__('filament-gtag::pages.fields.gtag_id.label')) ->helperText(__('filament-gtag::pages.fields.gtag_id.helper')) ->placeholder('G-XXXXXXXXXX') ->nullable(), Toggle::make('enabled') ->label(__('filament-gtag::pages.fields.enabled.label')) ->helperText(__('filament-gtag::pages.fields.enabled.helper')), Toggle::make('anonymize_ip') ->label(__('filament-gtag::pages.fields.anonymize_ip.label')) ->helperText(__('filament-gtag::pages.fields.anonymize_ip.helper')), ])->columns(2), Section::make(__('filament-gtag::pages.sections.advanced.heading')) ->description(__('filament-gtag::pages.sections.advanced.description')) ->collapsed() ->schema([ KeyValue::make('additional_config') ->label(__('filament-gtag::pages.fields.additional_config.label')) ->helperText(__('filament-gtag::pages.fields.additional_config.helper')) ->keyLabel(__('filament-gtag::pages.fields.additional_config.key_label')) ->valueLabel(__('filament-gtag::pages.fields.additional_config.value_label')), ]), ]); } } ``` -------------------------------- ### GtagServiceProvider Registration Source: https://github.com/jeffersongoncalves/filament-gtag/blob/3.x/resources/boost/skills/filament-gtag-development/SKILL.md The service provider registers the Google Tag tracking script into the application's head section using Filament render hooks. ```php namespace JeffersonGoncalves\Filament\Gtag; use Filament\Support\Facades\FilamentView; use Filament\View\PanelsRenderHook; use Illuminate\Contracts\View\View; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; class GtagServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package->name('filament-gtag') ->hasTranslations(); } public function packageRegistered(): void { FilamentView::registerRenderHook(PanelsRenderHook::HEAD_START, fn (): View => view('gtag::script')); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.