PHPackages                             astrogoat/gtm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. astrogoat/gtm

ActiveLibrary[API Development](/categories/api)

astrogoat/gtm
=============

A Google Tag Manager app for Strata

4.7.0(8mo ago)013.0k↓50%MITPHPPHP ^8.0CI passing

Since Jan 26Pushed 8mo ago4 watchersCompare

[ Source](https://github.com/astrogoat/gtm)[ Packagist](https://packagist.org/packages/astrogoat/gtm)[ Docs](https://github.com/astrogoat/gtm)[ GitHub Sponsors](https://github.com/astrogoat)[ RSS](/packages/astrogoat-gtm/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (42)Used By (0)

A GTM (Google Tag Manager) app for Strata
=========================================

[](#a-gtm-google-tag-manager-app-for-strata)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3426fbbe37c0c9bcf76f496b12d47ca8f333595b6f6485e5e54547ec764ff0f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617374726f676f61742f67746d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/astrogoat/gtm)[![GitHub Tests Action Status](https://camo.githubusercontent.com/736b63204471a08dd89698567b5f73af3873719ffea146f8d2ad7237aeeaf03b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f617374726f676f61742f67746d2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/astrogoat/gtm/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3089bc8c140fb9db370613c3e9879ef0efa49f2acf1dbd22c3f440a35f9f367d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f617374726f676f61742f67746d2f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/astrogoat/gtm/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6a33afa9f75b492027c9c33da6c76f244f7da663ef8ed4a34727e1d465dd1e31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617374726f676f61742f67746d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/astrogoat/gtm)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require astrogoat/gtm
```

If you plan on using the [flash-functionality](#flashing-data-for-the-next-request) you must install the GoogleTagManagerMiddleware, after the StartSession middleware:

```
// app/Http/Kernel.php

protected $middleware = [
    ...
    \Illuminate\Session\Middleware\StartSession::class,
    \Spatie\GoogleTagManager\GoogleTagManagerMiddleware::class,
    ...
];
```

Usage
-----

[](#usage)

This will require two includes to be added to `BRAND/layout/app.blade.php`

```

    ...
    @include('gtm::header-script')

    ...
    @include('gtm::body-script')

```

Your base dataLayer will also be rendered here. To add data, use the `set()` function.

```
// HomeController.php

public function index()
{
    GoogleTagManager::set('pageType', 'productDetail');

    return view('home');
}
```

This renders:

```

    dataLayer = [{"pageType":"productDetail"}];
    /* Google Tag Manager's script */

```

### Flashing data for the next request

[](#flashing-data-for-the-next-request)

The package can also set data to render on the next request. This is useful for setting data after an internal redirect.

```
// ContactController.php

public function getContact()
{
    GoogleTagManager::set('pageType', 'contact');

    return view('contact');
}

public function postContact()
{
    // Do contact form stuff...

    GoogleTagManager::flash('formResponse', 'success');

    return redirect()->action('ContactController@getContact');
}
```

After a form submit, the following dataLayer will be parsed on the contact page:

```

    dataLayer = [{"pageType":"contact","formResponse":"success"}];
    /* Google Tag Manager's script */

```

### Other Simple Methods

[](#other-simple-methods)

```
// Retrieve your Google Tag Manager id
$id = GoogleTagManager::id(); // GTM-XXXXXX

// Check whether script rendering is enabled
$enabled = GoogleTagManager::isEnabled(); // true|false

// Add data to the data layer (automatically renders right before the tag manager script). Setting new values merges them with the previous ones. Set also supports dot notation.
GoogleTagManager::set(['foo' => 'bar']);
GoogleTagManager::set('baz', ['ho' => 'dor']);
GoogleTagManager::set('baz.ho', 'doorrrrr');

// [
//   'foo' => 'bar',
//   'baz' => ['ho' => 'doorrrrr']
// ]
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Brett M](https://github.com/bmmage)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance58

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 71.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~50 days

Total

40

Last Release

266d ago

Major Versions

1.11.0 → 2.0.02023-01-27

2.7.0 → 3.x-dev2024-02-06

3.3.2 → 4.0.02024-04-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e9527ee45d5bf016d30f77ce27f61e964a126cf168255fe68625af4ae83bf26?d=identicon)[tonning](/maintainers/tonning)

---

Top Contributors

[![tonning](https://avatars.githubusercontent.com/u/7304678?v=4)](https://github.com/tonning "tonning (62 commits)")[![bmmage](https://avatars.githubusercontent.com/u/2388048?v=4)](https://github.com/bmmage "bmmage (11 commits)")[![miles-bot](https://avatars.githubusercontent.com/u/75677136?v=4)](https://github.com/miles-bot "miles-bot (11 commits)")[![BaffourAdu](https://avatars.githubusercontent.com/u/22221905?v=4)](https://github.com/BaffourAdu "BaffourAdu (2 commits)")[![iamkarsoft](https://avatars.githubusercontent.com/u/5146869?v=4)](https://github.com/iamkarsoft "iamkarsoft (1 commits)")

---

Tags

laravelgtmastrogoat

###  Code Quality

TestsPest

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/astrogoat-gtm/health.svg)

```
[![Health](https://phpackages.com/badges/astrogoat-gtm/health.svg)](https://phpackages.com/packages/astrogoat-gtm)
```

###  Alternatives

[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[hofmannsven/laravel-brevo

Laravel wrapper for Brevo's API v3 PHP library.

3450.2k](/packages/hofmannsven-laravel-brevo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
