PHPackages                             combindma/laravel-trail - 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. combindma/laravel-trail

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

combindma/laravel-trail
=======================

A simple package for tracking user activities on your Laravel website.

0.3.0(1mo ago)1232↓50%MITPHPPHP ^8.3CI passing

Since Dec 25Pushed 1mo agoCompare

[ Source](https://github.com/combindma/laravel-trail)[ Packagist](https://packagist.org/packages/combindma/laravel-trail)[ Docs](https://github.com/combindma/laravel-trail)[ RSS](/packages/combindma-laravel-trail/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (15)Used By (0)

A simple package for tracking user activities on your Laravel website.
======================================================================

[](#a-simple-package-for-tracking-user-activities-on-your-laravel-website)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9bac23fbf41ed36cdff30061965c7062e9bc4e4ba2a1fc63a8ba9a4ccb01eb92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6d62696e646d612f6c61726176656c2d747261696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/combindma/laravel-trail)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bbcd69de290d56e641782dec664640acf3d6500115efcc4d82ae84ee3b0a6d71/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d62696e646d612f6c61726176656c2d747261696c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/combindma/laravel-trail/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/eb0ac1a3c89d0a095143f3e33ee47c6f0a83f285f2506ccc31ee5951a45fb388/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d62696e646d612f6c61726176656c2d747261696c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/combindma/laravel-trail/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f50f5a1cd3570c4189bb83f0a09474a40069835d0df33114a8caa21df17b03a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6d62696e646d612f6c61726176656c2d747261696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/combindma/laravel-trail)

Laravel Trail is a powerful and easy-to-use package for tracking user activities on your Laravel website. Developed by Combind, this package automatically logs important information such as UTM tags, referrers, user actions, and more, giving you valuable insights into your users behavior and their journey through your website.

But WHY ?
---------

[](#but-why-)

The Laravel Trail is designed to help developers effortlessly capture and store user activity data on their websites. This package enables you to track vital information such as UTM tags, referrers, and user actions, which can be used to gain valuable insights into user behavior and website performance.

By storing this information, developers can easily integrate it with their preferred tracking tools, such as Google Analytics or other analytics platforms, to further analyze user interactions and optimize their websites for improved user experience, conversion rates and improve their marketing targeting.

Features
--------

[](#features)

- **Effortless Tracking**: Automatically track user activities without any additional code
- **Capture Important Data**: Log UTM tags, referrers, and user actions for valuable insights
- **Cookies Integration**: Store tracked data in cookies
- **Customizability**: Easily extend and modify the package to track additional data or events
- **Documentation &amp; Support**: Benefit from comprehensive documentation and support

About Combind Agency
--------------------

[](#about-combind-agency)

[Combine Agency](https://combind.ma?utm_source=github&utm_medium=banner&utm_campaign=laravel_trail) is a leading web development agency specializing in building innovative and high-performance web applications using modern technologies. Our experienced team of developers, designers, and project managers is dedicated to providing top-notch services tailored to the unique needs of our clients.

If you need assistance with your next project or would like to discuss a custom solution, please feel free to [contact us](mailto:hello@combind.ma) or visit our [website](https://combind.ma?utm_source=github&utm_medium=banner&utm_campaign=laravel_trail) for more information about our services. Let's build something amazing together!

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

[](#installation)

You can install the package via composer:

```
composer require combindma/laravel-trail
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-trail-config"
```

This is the contents of the published config file:

```
return [
     /*
     * The prefix key under which data is saved to the cookies.
     */
    'prefix' => env('TAIL_COOKIE_PREFIX', config('app.name', 'laravel')).'_',

    /*
     * The cookie duration in seconds used to store data. By default, we use 180 days.
     */
    'cookie_duration' => env('TAIL_COOKIE_DURATION', 60 * 24 * 180),

    /*
     * Enable or disable script rendering. Useful for local development.
     */
    'enabled' => env('TAIL_ENABLED', false),
];
```

Monitored Tags
--------------

[](#monitored-tags)

Laravel Trail automatically tracks and stores the following tags, providing valuable insights into user behavior, traffic sources, and user demographics:

1. **UTM Tags**

    - `utm_source`: Identifies the traffic source (e.g., google, newsletter, referral\_website).
    - `utm_medium`: Describes the marketing medium (e.g., cpc, email, social).
    - `utm_campaign`: Provides details about the specific marketing campaign or promotion (e.g., spring\_sale, newsletter\_april).
    - `utm_term`: Captures the keywords used for paid search campaigns (e.g., running+shoes, digital+marketing).
    - `utm_content`: Differentiates between multiple links within the same ad or content piece (e.g., logo\_link, text\_link).
2. **Additional Tags**

    - `anonymous_id`: A unique identifier for tracking anonymous users on your website.
    - `user_id`: A unique identifier for registered or logged-in users on your website.
    - `email`: A unique email for registered or logged-in users on your website.
    - `name`: Full name for registered or logged-in users on your website.
    - `landing_page`: The first page the user visits on your website during a session.
    - `exit_page`: The last page the user visits before leaving your website.
    - `ip_address`: The user's IP address, which can provide insights into their location and network.
    - `last_activity`: The date and time of the user's most recent activity on your website.
    - `user_agent`: The user agent string, which provides detailed information about the user's browser, operating system, and device.
    - `language`: The user's preferred language, as specified in their browser settings.
    - `referrer`: The URL of the referring website that sent the user to your website.
    - `referrer_code`: A unique code or ID associated with the referrer (e.g., an affiliate partner or referral program).
3. **Expected Tags for the futur**

    - `device`: The type of device used by the user (e.g., desktop, tablet, mobile).
    - `browser`: The user's web browser (e.g., Chrome, Firefox, Safari).
    - `operating_system`: The user's operating system (e.g., Windows, macOS, Android, iOS).
    - `screen_resolution`: The user's screen resolution.
    - `page_views`: The number of pages viewed by the user during a single session.
    - `conversion_date`: The date when a user completes a desired action or goal (e.g., making a purchase or signing up for a newsletter).

These tags can help you optimize your website for better user experience and higher conversion rates by giving you a deeper understanding of user interactions and traffic patterns.

Usage
-----

[](#usage)

### Add the setup middleware

[](#add-the-setup-middleware)

This middleware is responsable for setting: anonymous\_id, user\_id, exit\_page, landing\_page, last\_activity, user\_agent, ip\_address, language

```
// app/Http/Kernel.php
protected $middleware = [
    ...
    \Illuminate\Session\Middleware\StartSession::class,
    \Combindma\Trail\Middleware\TrailSetupMiddleware::class,
    ...
];
```

### Save UTM tags

[](#save-utm-tags)

You have 2 options to save the utm tags:

#### 1. In your controller

[](#1-in-your-controller)

```
    public function index(Request $request)
    {
        \Combindma\Trail\Facades\Trail::setUtmCookies($request);

        //...
    }
```

#### 2. Using a middleware in your route

[](#2-using-a-middleware-in-your-route)

```
   Route::group([ 'middleware' => ['web', \Combindma\Trail\Middleware\HandleUtmTagsMiddleware::class]], function () {
            Route::get('/test-trail', function (Request $request) {
                //...
            });
        });  //...
    }
```

### Save Referrer

[](#save-referrer)

You have 2 options to save the utm tags:

#### 1. In your controller

[](#1-in-your-controller-1)

```
    public function index(Request $request)
    {
        \Combindma\Trail\Facades\Trail::setReferrerCookies($request);

        //...
    }
```

#### 2. Using a middleware in your route

[](#2-using-a-middleware-in-your-route-1)

```
   Route::group([ 'middleware' => ['web', \Combindma\Trail\Middleware\CaptureReferrerMiddleware::class]], function () {
            Route::get('/test-trail', function (Request $request) {
                //...
            });
        });  //...
    }
```

### Save User ID or Email

[](#save-user-id-or-email)

You can capture a user id or email using an url with those parameters: user\_id or email.

For exemple: domaine.com?user\_id=123456&amp;email=

You have 2 options to save the user:

#### 1. In your controller

[](#1-in-your-controller-2)

```
    public function index(Request $request)
    {
        \Combindma\Trail\Facades\Trail::setUserCookie($request);

        //...
    }
```

#### 2. Using a middleware in your route

[](#2-using-a-middleware-in-your-route-2)

```
   Route::group([ 'middleware' => ['web', \Combindma\Trail\Middleware\CaptureUserMiddleware::class]], function () {
            Route::get('/test-trail', function (Request $request) {
                //...
            });
        });  //...
    }
```

### Identify a user

[](#identify-a-user)

The only required parameter is userId:

```
   \Combindma\Trail\Facades\Trail::identify($userId);//User id can be an email if you don't offer a sign-up in your website
   \Combindma\Trail\Facades\Trail::identify($userId, 'email@domain.com', 'full name'); //you may also save an email with a name
```

### Get the cookies data

[](#get-the-cookies-data)

In order to get the saved data you can request it using:

```
   \Combindma\Trail\Facades\Trail::data($request);
   \Combindma\Trail\Facades\Trail::data(); //Behind the scene uses request() helper
```

This will return a formatted data object:

```
    readonly class TrailDto
    {
        public function __construct(
            public string $anonymousId,
            public ?string $userId,
            public ?string $email,
            public ?string $name,
            public ?string $landingPage,
            public ?string $exitPage,
            public ?string $lastActivity,
            public ?string $ipAddress,
            public ?string $language,
            public ?string $userAgent,
            public ?string $referrer,
            public ?string $referrerCode,
            public ?string $utmSource,
            public ?string $utmMedium,
            public ?string $utmCampaign,
            public ?string $utmTerm,
            public ?string $utmContent,
    ) {
    }
}
```

### Additional methods

[](#additional-methods)

```
   \Combindma\Trail\Facades\Trail::disable(); //Disable in the fly
   \Combindma\Trail\Facades\Trail::enable(); //Enable in the fly
   \Combindma\Trail\Facades\Trail::getAnonymousId(); //Get anonymous id
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Combind](https://github.com/combindma)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~202 days

Total

14

Last Release

50d ago

PHP version history (2 changes)0.0.1PHP ^8.2

0.2.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/31b418bcbabafab33631fd151a64d3e18035f728ad195814aa4656d862610fcd?d=identicon)[combindma](/maintainers/combindma)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![omarherri](https://avatars.githubusercontent.com/u/12627384?v=4)](https://github.com/omarherri "omarherri (1 commits)")

---

Tags

laravelcombindmalaravel-trail

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/combindma-laravel-trail/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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