PHPackages                             ubeeqo/laravel-sift - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ubeeqo/laravel-sift

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ubeeqo/laravel-sift
===================

A Laravel 5 package for Sift Science

04.1kPHP

Since Jul 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ubeeqo/laravel-sift)[ Packagist](https://packagist.org/packages/ubeeqo/laravel-sift)[ RSS](/packages/ubeeqo-laravel-sift/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Sift
============

[](#laravel-sift)

A [Laravel 5](https://laravel.com/) package for [Sift Science](https://siftscience.com/).

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

[](#installation)

Install the package using Composer

```
composer require ubeeqo/laravel-sift

```

Next, add the following to the `providers` array in config/app.php

```
ubeeqo\LaravelSift\SiftServiceProvider::class,
```

Register the facade by adding the following line to the `aliases` array in config/app.php

```
'SiftScience' => ubeeqo\LaravelSift\Facades\SiftScience::class,
```

Config
------

[](#config)

You can publish the configuration file using the following artisan command

```
php artisan vendor:publish --provider="ubeeqo\LaravelSift\SiftServiceProvider"

```

The default config file will check for a `SIFT_API_KEY` and `SIFT_JAVASCRIPT_KEY` in your .env file.

Usage
-----

[](#usage)

### JavaScript Snippet

[](#javascript-snippet)

To add the JavaScript snippet to your pages, include the following line immediately after the opening body tag in your master blade template:

```
@include('sift::snippet')
```

This will track user interaction with your site using a session ID as well as the user's email when authenticated. For more information on the JavaScript snippet itself, consult the [Sift Science documentation](https://siftscience.com/developers/docs/javascript/javascript-api).

### Customizing the Sift User ID

[](#customizing-the-sift-user-id)

By default the package uses the [getAuthIdentifier()](https://github.com/laravel/framework/blob/5.2/src/Illuminate/Contracts/Auth/Authenticatable.php#L19) method to get an identifier (the user ID in most cases) for a user when tracking auth events. This value can be customized by adding a `getSiftId()` method to your user model that will return the value you want to track. This is useful if you don't want to expose your user IDs (the value is visible in the JavaScript snippet) or have another value you'd like to use. Keep in mind that using email addresses (or any other value that may change) may not be a good idea because you will lose your reference to the user in Sift if the value changes.

It is recommended that you use `SiftScience::getUserId($user)` to get a user's Sift ID when reporting your own events, as this is the method used internally. The `$user` arg is optional and will default to the currently authenticated user. It currently uses the value from the previously mentioned `getSiftId()` method and will fall back to `getAuthIdentifier()`.

If you are customizing your identifier be aware that if you change it in the future, another user will be created in Sift and their score may be impacted. Also be sure to check out the [allowed characters](https://support.siftscience.com/hc/en-us/articles/202116248-What-characters-can-I-use-in-my-User-ID-)).

### Tracking Events

[](#tracking-events)

By default the package tracks successful and failed logins as well as logouts, but you'll probably want to track other actions like transactions.

To track events, you'll want to interact with the SiftClient class, which can be accessed as shown below:

```
// Import the facade
use SiftScience;

// Returns the SiftClient class
SiftScience::client();

// Track an event
SiftScience::client()->track('$transaction', [
    '$user_id'          => SiftScience::getUserId(),
    '$amount'           => 1000000,
    '$currency_code'    => 'USD',
    '$user_email'       => $user->email,
    '$transaction_type' => '$sale',
    '$transaction_status' => '$success',
    '$session_id'       => SiftScience::getSessionId(),
]);
```

In the example above you'll notice `SiftScience::getSessionId()`. This gets an identifier stored in the current session using the key `'sift_session_id'`. You can also pass a session store as an argument for situations (like queues) where there is not a current session.

For more on how to use the SiftClient class, consult the [sift-php documentation](https://github.com/SiftScience/sift-php) and the [events API reference](https://siftscience.com/developers/docs/php/events-api/overview).

### Queues

[](#queues)

You may want to use a queue to track certain events to avoid slowing down your application. The built-in support for auth event tracking uses the queue, but as of now you will have to implement queueing yourself. Suggestions are welcome for an elegant way of adding queue support directly to this package.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/9ce4288739722a543c862a594d786cb5ad9c81a7a1b24d2b9d73d2d47dcaa428?d=identicon)[aspitzer](/maintainers/aspitzer)

### Embed Badge

![Health badge](/badges/ubeeqo-laravel-sift/health.svg)

```
[![Health](https://phpackages.com/badges/ubeeqo-laravel-sift/health.svg)](https://phpackages.com/packages/ubeeqo-laravel-sift)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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