Google Tag Manager - v1.0.0

Configuration

Full reference for config/google-tag-manager.php. Publish it with:

php artisan vendor:publish --tag=google-tag-manager-config

snippet

Controls the client-side <script> / <noscript> snippet emitted by the Blade directives and the React/Vue snippet components.

'snippet' => [
    'enabled'      => true,
    'container_id' => env( 'GTM_CONTAINER_ID' ),
],
Key Type Default Purpose
enabled bool true When false, the snippet renders nothing. Handy for disabling GTM in local / testing environments without removing the directives from your layout.
container_id string | null env('GTM_CONTAINER_ID') The GTM container ID (e.g. GTM-XXXXXXX). When null or empty, the snippet renders nothing.

api

Controls the server-side Tag Manager API client.

'api' => [
    'base_url'  => 'https://www.googleapis.com/tagmanager/v2',
    'timeout'   => 30,
    'cache_ttl' => 300,
],
Key Type Default Purpose
base_url string Tag Manager API v2 endpoint The API base URL. Rarely changed; useful only for stubbed integration tests.
timeout int 30 Per-request HTTP timeout in seconds. Falls back to 30s when set to null.
cache_ttl int 300 Seconds to cache successful API responses. Set to 0 to disable caching entirely — recommended only when debugging stale-data issues.

scopes

Google OAuth scopes contributed to the shared consent screen via the ap.google.scopes filter hook.

'scopes' => [
    'https://www.googleapis.com/auth/tagmanager.readonly',
],

Add scopes here to expand what the consent screen requests. The v1 default is read-only; if a future major release adds write features, opt in by adding tagmanager.edit.containers or tagmanager.publish.

routes

Controls the HTTP routes that back the React and Vue admin components.

'routes' => [
    'enabled'    => true,
    'prefix'     => 'google-tag-manager',
    'middleware' => [ 'web', 'auth' ],
],
Key Type Default Purpose
enabled bool true When false, the package's routes are not registered. Correct for headless / API-only apps that only use the Blade directive.
prefix string 'google-tag-manager' The route group prefix. Change to admin/gtm or similar to nest the endpoints under your admin panel.
middleware array [ 'web', 'auth' ] Middleware applied to every route. Add can:view_tag_manager or your own tenant-scoped middleware here.

The routes registered:

  • GET {prefix}/container-overviewgoogle-tag-manager.container-overview
  • GET {prefix}/tagsgoogle-tag-manager.tags

See HTTP Routes for the request/response schema.