Laravel Firebase Analytics adds blade directives to initialize, log events and set user properties for Firebase Analytics.
Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.
If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.
You can install the package via composer:
composer require renoki-co/laravel-firebase-analytics
Initialize in your <body>
tag using the @initializeFirebaseAnalytics
directive, passing the version of Firebase JS scripts and the Firebase configuration parameters:
<body>
@initializeFirebaseAnalytics([
'version' => '7.15.5',
'config' => [
'apiKey' => 'some-key',
'authDomain' => 'firebaseapp',
...
],
])
...
</body>
Afterwards, you can trigger events as stated in Firebase Analytics docs:
<body>
@initializeFirebaseAnalytics([
'version' => '7.15.5',
'config' => [
'apiKey' => 'some-key',
'authDomain' => 'firebaseapp',
...
],
])
@if ($loginSuccessful)
@firebaseAnalyticsEvent([
'name' => 'login',
'parameters' => [
'method' => 'email',
],
])
@endif
</body>
Or for logged in users or sessions, you can set default user properties:
<body>
@initializeFirebaseAnalytics([
'version' => '7.15.5',
'config' => [
'apiKey' => 'some-key',
'authDomain' => 'firebaseapp',
...
],
])
@auth
@firebaseAnalyticsUserProperties([
'name' => auth()->user()->name,
'age' => auth()->user()->age,
])
@endauth
</body>
More details about the usage can be found here:
- https://firebase.google.com/docs/analytics/get-started
- https://firebase.google.com/docs/analytics/events
- https://firebase.google.com/docs/analytics/user-properties
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.