Google Tag Manager - v1.0.0
CMS Framework Widgets
When the artisanpack-ui/cms-framework package is installed, the container overview and tag list components are automatically exposed as CMS admin dashboard widgets.
The wrappers (ContainerOverviewWidget and TagListWidget) extend the underlying Livewire components and implement the CMS framework's AdminWidgetInterface, so instantiating a widget via the CMS AdminWidgetManager renders the same UI as <livewire:google-tag-manager::container-overview />.
Automatic registration
When both artisanpack-ui/cms-framework and livewire/livewire are installed, the service provider:
- Registers both wrapper classes with the CMS's
AdminWidgetManagerunder the keysgoogle-tag-manager-container-overviewandgoogle-tag-manager-tag-list. - Registers them as Livewire components under
google-tag-manager::cms-container-overview-widgetandgoogle-tag-manager::cms-tag-list-widgetso the CMS dashboard can render them.
If either peer package is missing, registration silently no-ops — the wrappers only make sense with both.
Widget metadata
Each wrapper exposes a getWidgetInfo() static method returning:
[
'title' => __( '...' ),
'description' => __( '...' ),
'capability' => 'view_tag_manager',
'default_options' => [
// per-widget defaults
],
]
The capability is view_tag_manager — configure it on your CMS role/capability matrix or override the widget class if you want a different capability name.
default_options starts empty for account/container/workspace IDs — the CMS admin fills them in per-widget when adding to the dashboard.
Overriding
To ship your own widget instead:
namespace App\Widgets;
use ArtisanPackUI\CMSFramework\Modules\AdminWidgets\Contracts\AdminWidgetInterface;
use ArtisanPackUI\GoogleTagManager\Livewire\ContainerOverview;
class MyContainerWidget extends ContainerOverview implements AdminWidgetInterface
{
public static function getWidgetInfo(): array
{
return [
'title' => 'My container',
'description' => 'Overview for the marketing container',
'capability' => 'view_marketing_analytics',
'default_options' => [
'accountId' => env( 'GTM_MARKETING_ACCOUNT_ID' ),
'containerId' => env( 'GTM_MARKETING_CONTAINER_ID' ),
'workspaceId' => null,
],
];
}
}
Register with the CMS from your own service provider:
$manager = $this->app->make( \ArtisanPackUI\CMSFramework\Modules\AdminWidgets\Services\AdminWidgetManager::class );
$manager->register( 'my-container-widget', \App\Widgets\MyContainerWidget::class );
Related
- Livewire components — the underlying components the widgets extend
- CmsFramework API reference — the wrapper class API