Google Tag Manager - v1.0.0
Blade Directives
Four directives registered by the package.
@gtmSnippet
Emits both the head <script> block and the body <noscript> fallback. Renders nothing when the snippet is unconfigured.
Compiles to:
<?php echo app( \ArtisanPackUI\GoogleTagManager\Snippet\SnippetRenderer::class )->render(); ?>
@gtmSnippetHead
Emits just the head <script> block. For placement immediately inside <head>.
Compiles to:
<?php echo app( \ArtisanPackUI\GoogleTagManager\Snippet\SnippetRenderer::class )->renderHead(); ?>
@gtmSnippetBody
Emits just the body <noscript> fallback. For placement immediately after <body>.
Compiles to:
<?php echo app( \ArtisanPackUI\GoogleTagManager\Snippet\SnippetRenderer::class )->renderBody(); ?>
@gtmRoutes
Emits an inline <script> block that publishes the resolved route URLs to window.__apGtmRoutes. The React and Vue clients read this global to know where the HTTP routes live when the host app has changed google-tag-manager.routes.prefix.
Compiles to a call into RouteScript::render(), which builds the script block server-side.
Include it in your Blade layout before your JS bundle:
<head>
@gtmRoutes
@vite(['resources/js/app.tsx'])
</head>
Only necessary for React and Vue apps that use the container overview or tag list components. Blade / Livewire apps do not need it.