vitorbizarra/laravel-gtag

This is my package laravel-gtag

2.0.2 2024-05-07 13:58 UTC

This package is auto-updated.

Last update: 2024-10-08 03:33:08 UTC


README

Latest Version on Packagist Software License GitHub Code Style Action Status Total Downloads

An package to easily setup Google GTag in Laravel apps

Installation

You can install the package via composer:

composer require vitorbizarra/laravel-gtag

You can publish the config file with:

php artisan vendor:publish --tag="laravel-gtag-config"

This is the contents of the published config file:

return [
    /*
     * The Google Analytics id, should be a code that looks something like "G-xxxx".
     */
    'id' => env('GTAG_ID', ''),

    /*
     * Enable or disable script rendering. Useful for local development.
     */
    'enabled' => env('GTAG_ENABLED', true),

    /*
     * Configures the Google Analytics script domain.
     */
    'domain' => env('GTAG_DOMAIN', 'www.googletagmanager.com'),
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-gtag-views"

Usage

{{-- layout.blade.php --}}
<head>
  @include('gtag::script')
  {{-- ... --}}
</head>

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.