PHPackages                             code-tree-dev/laravel-utm-tracker - 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. code-tree-dev/laravel-utm-tracker

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

code-tree-dev/laravel-utm-tracker
=================================

A lightweight Laravel package that adds a middleware to automatically capture and store UTM parameters (like utm\_source, utm\_medium, utm\_campaign) from incoming requests. Makes it easy to track traffic sources across sessions for analytics, marketing attribution, or lead tracking.

2.0.2(6mo ago)273MITPHPPHP ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4CI passing

Since Oct 24Pushed 6mo agoCompare

[ Source](https://github.com/code-tree-dev/laravel-utm-tracker)[ Packagist](https://packagist.org/packages/code-tree-dev/laravel-utm-tracker)[ Docs](https://github.com/code-tree-dev/laravel-utm-tracker)[ RSS](/packages/code-tree-dev-laravel-utm-tracker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Laravel UTM Tracker
===================

[](#laravel-utm-tracker)

[![Latest Version on Packagist](https://camo.githubusercontent.com/53dbec06a74432879575161c003f9f36a7f635a761be4ac0bd8ecb3e879aeb8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64652d747265652d6465762f6c61726176656c2d75746d2d747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/code-tree-dev/laravel-utm-tracker)[![Total Downloads](https://camo.githubusercontent.com/55d45111f97a0a170f2481191cc692e8601142f69fd1076b2c0a5c38e1391035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64652d747265652d6465762f6c61726176656c2d75746d2d747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/code-tree-dev/laravel-utm-tracker)[![GitHub Actions](https://github.com/code-tree-dev/laravel-utm-tracker/actions/workflows/main.yml/badge.svg)](https://github.com/code-tree-dev/laravel-utm-tracker/actions/workflows/main.yml/badge.svg)

Laravel UTM Tracker is a package for Laravel that automatically or manually tracks UTM parameters from your visitors and stores them in your database. It is ideal for marketing attribution, analytics, and campaign tracking. The package is easy to configure, extend, and integrates seamlessly with Laravel middleware and facades.

Features
--------

[](#features)

- Automatic UTM tracking via middleware
- Manual UTM tracking via Facade
- Stores UTM data in the database, session, or cookie
- Easily extendable for custom UTM parameters
- Ready for analytics and marketing attribution

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

[](#installation)

Install the package via Composer:

```
composer require code-tree-dev/laravel-utm-tracker
```

Publish the config and migration files (optional):

```
php artisan vendor:publish --provider="CodeTreeDev\LaravelUtmTracker\LaravelUtmTrackerServiceProvider"
```

Run the migrations if using database storage:

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

You can configure the package in `config/laravel-utm-tracker.php`:

- `storage`: Where to store UTM data (`session`, `cookie`, or `database`)
- `parameters`: Default UTM parameters to track
- `custom_parameters`: Add your own custom UTM parameters
- `cookie_lifetime`: Lifetime for cookies (if using cookie storage)
- `auto_track`: Enable/disable automatic tracking via middleware
- `table`: Table name for database storage

Usage
-----

[](#usage)

### Automatic Tracking (Middleware)

[](#automatic-tracking-middleware)

By default, the package's middleware is registered and will automatically capture UTM parameters from incoming requests:

```
// No action needed if auto_track is enabled in config.
```

### Manual Tracking (Facade)

[](#manual-tracking-facade)

You can manually create a UTM visit record using the Facade:

```
use LaravelUtmTracker;

LaravelUtmTracker::track([
    'utm_source' => 'newsletter',
    'utm_medium' => 'email',
    'utm_campaign' => 'spring_sale',
    // ...other fields...
]);
```

### Testing

[](#testing)

Run the test suite with:

```
composer test
```

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

[](#contributing)

Contributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) files for details.

- Open issues for bugs or feature requests
- Submit pull requests for improvements

Security
--------

[](#security)

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

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md) for recent changes.

Credits
-------

[](#credits)

- [Code-Tree.dev](https://github.com/code-tree-dev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE.md) for details.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

206d ago

Major Versions

1.0.0 → 2.0.02025-10-24

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

2.0.0PHP ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/18ccc938fc1da8947ce50b685736f1c8764b46df225d3a2b31a542f810ba42cf?d=identicon)[codetreedev](/maintainers/codetreedev)

---

Top Contributors

[![Trukes](https://avatars.githubusercontent.com/u/6023213?v=4)](https://github.com/Trukes "Trukes (10 commits)")

---

Tags

laravellaravel-frameworklaravel-packagephputmutm-parameterscode-tree-devlaravel-utm-tracker

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/code-tree-dev-laravel-utm-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/code-tree-dev-laravel-utm-tracker/health.svg)](https://phpackages.com/packages/code-tree-dev-laravel-utm-tracker)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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