- Install the package via composer:
composer require ngiraud/laravel-cookies-analytics
- Install the CookieConsent plugin
yarn add cookieconsent
or
npm install cookieconsent --save
- You can activate/deactivate cookies and google analytics by settings environment variables in your
.env
file :
GOOGLE_ANALYTICS_ENABLED
GOOGLE_ANALYTICS_ID (mandatory if GOOGLE_ANALYTICS_ENABLED is set to true)
COOKIES_ENABLED
- Add the view to the top of your
<head>
section :
@include('analytics::scripts')
- Add the css for the CookieConsent plugin in your css file :
@import "../../node_modules/cookieconsent/build/cookieconsent.min.css";
- And these lines in your vuejs index file :
import {CookieConsent} from 'cookieconsent';
if (window.cookieSettings.enabled === true) {
document.addEventListener('DOMContentLoaded', () => {
cookieconsent.initialise(window.cookieSettings.content);
});
}
- If you want to customize the popup and the message in the config file, you can publish and edit the config file :
php artisan vendor:publish --tag=analytics-config
Don't forget to generate and include your css & js files.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email contact@ngiraud.me instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.