Looking to hire Laravel developers? Try LaraJobs

laravel-nova-google-analytics-4 maintained by panchania83

Description
Google Analytics 4 integration with Laravel Nova
Last update
2023/10/31 10:35 (dev-main)
License
Downloads
381

Comments
comments powered by Disqus

Google Analytics integration with Laravel Nova

Latest Stable Version Total Downloads License PHP Version Require

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require panchania83/laravel-nova-google-analytics-4

Optionally, you can publish the config file of this package with this command:

php artisan vendor:publish --tag="analytics-config"

The following config file will be published in config/analytics.php

return [

    /*
     * The property id of which you want to display data.
     */
    'property_id' => env('PROPERTY_ID'),

    /*
     * Path to the client secret json file. Take a look at the README of this package
     * to learn how to get this file. You can also pass the credentials as an array
     * instead of a file path.
     */
    'service_account_credentials_json' => storage_path('app/analytics/service-account-credentials.json'),
];

Also add this to the .env for your Nova app:

PROPERTY_ID=

Usage

Next up, you must register the card with Nova. This is typically done in the cards method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvider.php

// ...

public function cards()
{
    return [
        // ...
        new \panchania83\LaravelNovaGoogleAnalytics4\VisitorsMetric,
        new \panchania83\LaravelNovaGoogleAnalytics4\GoogleAnalyticsCard,
    ];
}

License

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