PHPackages                             script-artist/laravel-amplitude-analytics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. script-artist/laravel-amplitude-analytics

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

script-artist/laravel-amplitude-analytics
=========================================

A Laravel package to work with Amplitude.

00PHP

Since Jun 7Pushed 2y agoCompare

[ Source](https://github.com/ScriptArtist/laravel-amplitude-analytics)[ Packagist](https://packagist.org/packages/script-artist/laravel-amplitude-analytics)[ RSS](/packages/script-artist-laravel-amplitude-analytics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

A Laravel package to work with Amplitude.
=========================================

[](#a-laravel-package-to-work-with-amplitude)

[![Latest Version on Packagist](https://camo.githubusercontent.com/74e0f1044f4034f0ab6b7cb0eee525430cf11d845b8637a32714fc74d6c50086/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68617368636f6465372f6c61726176656c2d616d706c69747564652d616e616c79746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/francescomalatesta/laravel-amplitude)[![Build Status](https://camo.githubusercontent.com/b8af7490b55227021168b622a1319a81ae2a09942fb6eed122066e85c090a673/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6672616e636573636f6d616c6174657374612f6c61726176656c2d616d706c69747564652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/francescomalatesta/laravel-amplitude)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1d8548957edf5bfd93cdd7a9f461ef743d45db700b22b21fb3f683971e5c6135/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6672616e636573636f6d616c6174657374612f6c61726176656c2d616d706c69747564652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/francescomalatesta/laravel-amplitude/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/11bfc107772c463dda2811b050a17a396d042dc581d69ee58df35b7bd3173546/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6672616e636573636f6d616c6174657374612f6c61726176656c2d616d706c69747564652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/francescomalatesta/laravel-amplitude)

[![](laravel-amplitude.png)](laravel-amplitude.png)

This package will be your best friend if you need to track events for your Laravel application in Amplitude.

This package is compatible with the 5.8 version of Laravel.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require hashcode7/laravel-amplitude-analytics
```

Do not forget to publish the config file with Artisan:

```
artisan vendor:publish
```

To be up and running, just add the Amplitude API Key of your project in the `.env` file, using `AMPLITUDE_API_KEY` as key.

If you want to use the `Amplitude` facade, remember to add the following line to your `config/app.php`, in the `aliases` item.

```
'aliases' => [
    ...

    'Amplitude' => LaravelAmplitude\Facades\Amplitude::class
]
```

Usage
-----

[](#usage)

Laravel Amplitude uses a simple syntax to track your product events easily.

### Setting the User Id

[](#setting-the-user-id)

First of all, before sending anything, you will need to set the User ID.

```
Amplitude::setUserId('user_id');
```

Note: setting the user id is MANDATORY. Otherwise, you will get an error when trying to send data to Amplitude.

### Sending Events

[](#sending-events)

Once the user id is set, you are ready to send events to your Amplitude project.

```
// simple sending...
Amplitude::sendEvent('app_opened');

// sending with properties...
Amplitude::sendEvent('subscription_paid', ['was_trial' => true]);
```

Also, you can change the user properties with the dedicated method `setUserProperties`:

```
// properties new values are set here
Amplitude::setUserProperties([
    'trial' => false,
    'plan' => 'professional'
]);

// data is sent to Amplitude here
Amplitude::sendEvent('subscription_paid', ['was_trial' => true]);
```

IMPORTANT: the properties will be sent to Amplitude at the next `sendEvent` call. Without any other call to `sendEvent`, the new user properties are not going to be saved.

### Queueing Events

[](#queueing-events)

If send a lot of events and you want to keep your performances good, you may choose events queueing instead of the simple sending you just saw.

With events queueing, **you will send all your events once the request is over**, instead of making different API calls during the request lifecycle.

To use it, just switch your `sendEvent` calls to `queueEvent` method.

```
// simple sending...
Amplitude::queueEvent('app_opened');

// sending with properties...
Amplitude::queueEvent('subscription_paid', ['was_trial' => true]);
```

Nothing more to do! When the request will be finished, Laravel Amplitude will automatically trigger the send operation of your data.

However, if you want more control and you want to send your queued events in your code, you can do it manually with a call to the `sendQueuedEvents` method.

```
// queueing an event...
Amplitude::queueEvent('app_opened');

// queueing another event...
Amplitude::queueEvent('subscription_paid', ['was_trial' => true]);

// send them!
Amplitude::sendQueuedEvents();
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Francesco Malatesta](https://github.com/francescomalatesta)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 88% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f809fa99f2cb0b037dccba26df877eb8bdbce3fa75c8ba86bca50115b2d3676?d=identicon)[ScriptArtist](/maintainers/ScriptArtist)

---

Top Contributors

[![francescomalatesta](https://avatars.githubusercontent.com/u/1940952?v=4)](https://github.com/francescomalatesta "francescomalatesta (22 commits)")[![ScriptArtist](https://avatars.githubusercontent.com/u/30506483?v=4)](https://github.com/ScriptArtist "ScriptArtist (3 commits)")

### Embed Badge

![Health badge](/badges/script-artist-laravel-amplitude-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/script-artist-laravel-amplitude-analytics/health.svg)](https://phpackages.com/packages/script-artist-laravel-amplitude-analytics)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
