Please consider using https://github.com/spatie/laravel-googletagmanager.
Google tag manager features including events, ecommerce, and dataLayer support
Authors: Andrew Mc Cormack, Simone Todaro
Require this package with composer:
composer require cyber-duck/laravel-google-tag-manager
Add the following to the list of service providers in your config/app.php file
'CyberDuck\LaravelGoogleTagManager\GTMServiceProvider',Add the following alias to your config/app.php file
'GTM' => 'CyberDuck\LaravelGoogleTagManager\Facades\GTM',Publish configuration file:
php artisan vendor:publish --provider="CyberDuck\LaravelGoogleTagManager\GTMServiceProvider"Configure your GTM-XXXXX ID in config/gtm.php
Within your main blade layout template include the GTM blade template
@include('tracking::gtm')\GTM::data('paramName', 'paramValue')\GTM::event('eventName')\GTM::flash()
return redirect()->action('...');Coming soon!!!