Google Tag Manager - v1.0.0
Livewire
Two Livewire 3 components ship with the package. Both extend Livewire\Component and use the shared HandlesTagManagerRefresh concern for connection detection and error handling.
google-tag-manager::container-overview
Renders the container overview panel: container name, public ID, workspace name, tag/trigger/variable counts, and the latest published version.
Mounting
<livewire:google-tag-manager::container-overview
account-id="123456"
container-id="654321"
workspace-id="1" />
Props:
| Prop | Type | Required | Purpose |
|---|---|---|---|
accountId |
string | Yes | GTM account ID. |
containerId |
string | Yes | GTM container ID (numeric, not the public GTM-XXXX). |
workspaceId |
string | null | No | Specific workspace. When null, the fetcher uses the default workspace. |
Actions
refresh()— re-fetches from the API. Useful on a poll or after a user action.
Published state (Livewire-visible properties)
name,publicId,workspaceNametagCount,triggerCount,variableCountlatestVersionName,latestVersionId(nullable — a container that has never been published has neither)hasData—trueonce the initial fetch completes successfullyerrorMessage— a human-readable string when the fetch failsbaseInstalled—falsewhen the base package isn't installed; the view renders a call-to-action
google-tag-manager::tag-list
Renders every tag in a workspace with client-side sort and pagination.
Mounting
<livewire:google-tag-manager::tag-list
account-id="123456"
container-id="654321"
workspace-id="1" />
Props:
| Prop | Type | Required | Purpose |
|---|---|---|---|
accountId |
string | Yes | GTM account ID. |
containerId |
string | Yes | GTM container ID. |
workspaceId |
string | Yes | Workspace ID — required (unlike container overview). |
Actions
refresh()— re-fetches the tag list from the API.sortByColumn( string $column )— sorts byname,type, orstatus. Second click on the same column flips direction. Unknown columns are ignored.nextPage()/previousPage()— client-side pagination over the already-fetched rows.
Published state
rows— the full list of tags with firing triggers already joined by namesortBy,sortDir,page,perPage— the visible sort / pagination stateerrorMessage,baseInstalled— same semantics as the container overview
The paginated / sorted view is computed in render() and passed to the view as $visibleRows and $totalPages — the $rows array is never mutated by sort or pagination.
Customizing the views
Publish the views:
php artisan vendor:publish --tag=google-tag-manager-views
The templates land at resources/views/vendor/google-tag-manager/livewire/. Edit them freely — the Livewire class contract stays the same, so your custom markup drives the same actions.
Testing
Use Livewire's test helpers:
use Livewire\Livewire;
Livewire::test( 'google-tag-manager::tag-list', [
'accountId' => '1',
'containerId' => '2',
'workspaceId' => '3',
] )
->assertSet( 'baseInstalled', true )
->call( 'sortByColumn', 'name' )
->assertSet( 'sortDir', 'asc' );
See Testing for the full test setup including how to stub the TagManagerClient so tests don't hit the network.