PHPackages                             vismutx/laravel-utm-forwarder - 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. vismutx/laravel-utm-forwarder

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

vismutx/laravel-utm-forwarder
=============================

Keeps track of the original UTM parameters

1.0(5y ago)012MITPHPPHP ^7.4

Since Jan 29Pushed 3y agoCompare

[ Source](https://github.com/vismutx/laravel-utm-forwarder)[ Packagist](https://packagist.org/packages/vismutx/laravel-utm-forwarder)[ Docs](https://github.com/spatie/laravel-utm-forwarder)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/vismutx-laravel-utm-forwarder/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

UNFINISHED &amp; NOT ON PACKAGIST!
----------------------------------

[](#unfinished--not-on-packagist)

Keeps track of the original UTM (or other analytics) parameters
===============================================================

[](#keeps-track-of-the-original-utm-or-other-analytics-parameters)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d93e4b346880d44573ad07364494f68decb721993c7f7f0f61c3fc73425becd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d616e616c79746963732d747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-analytics-tracker)[![GitHub Tests Action Status](https://camo.githubusercontent.com/daaf2e5d792bd8f4d945113d15d85fccad2807887a6519914e31ab41abf99a9f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d616e616c79746963732d747261636b65722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/laravel-analytics-tracker/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/842e4a3f6886e1d12515628474f13edd9c8d180bd118fce2c13d63481f343421/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d616e616c79746963732d747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-analytics-tracker)

Cross domain analytics is hard. This package helps you to keep track of the visitor's original UTM parameters, referer header and other analytics parameters. You can then submit these parameters along with a form submission or add them to a link to another domain you track.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/88c325c45039df2934d447927e3a43889dc9e114bee16b868ae6e1efbad3c318/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d75746d2d666f727761726465722e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-utm-forwarder)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-analytics-tracker
```

The package works via a middleware that needs to be added to the `web` stack in your `kernel.php` file. Make sure to register this middleware after the `StartSession` middleware.

```
// app/Http/Kernel.php

protected $middlewareGroups = [
    'web' => [
        // ...
        \Illuminate\Session\Middleware\StartSession::class,
        // ...

        \Spatie\AnalyticsTracker\Middleware\TrackAnalyticsParametersMiddleware::class,
    ],
];
```

To configure the tracked parameters or how they're mapped on the URL parameters, you can publish the config file using:

```
php artisan vendor:publish --provider="Spatie\AnalyticsTracker\AnalyticsTrackerServiceProvider"
```

This is the contents of the published config file:

```
return [
    /*
     * These are the analytics parameters that will be tracked when a user first visits
     * the application. The configuration consists of the parameter's key and the
     * source to extract this key from.
     *
     * Available sources can be found in the `\Spatie\AnalyticsTracker\Sources` namespace.
     */
    'tracked_parameters' => [
        [
            'key' => 'utm_source',
            'source' => Spatie\AnalyticsTracker\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_medium',
            'source' => Spatie\AnalyticsTracker\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_campaign',
            'source' => Spatie\AnalyticsTracker\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_term',
            'source' => Spatie\AnalyticsTracker\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_content',
            'source' => Spatie\AnalyticsTracker\Sources\RequestParameter::class,
        ],
        [
            'key' => 'referer',
            'source' => Spatie\AnalyticsTracker\Sources\CrossOriginRequestHeader::class,
        ],
    ],

    /**
     * We'll put the tracked parameters in the session using this key.
     */
    'session_key' => 'tracked_analytics_parameters',

    /*
     * When formatting an URL to add the tracked parameters we'll use the following
     * mapping to put tracked parameters in URL parameters.
     *
     * This is useful when using an analytics solution that ignores the utm_* parameters.
     */
    'parameter_url_mapping' => [
        'utm_source' => 'utm_source',
        'utm_medium' => 'utm_medium',
        'utm_campaign' => 'utm_campaign',
        'utm_term' => 'utm_term',
        'utm_content' => 'utm_content',
        'referer' => 'referer',
    ],
];
```

Usage
-----

[](#usage)

The easiest way to retrieve the tracked parameters is by resolving the `TrackedAnalyticsParameters` class:

```
use Spatie\AnalyticsTracker\AnalyticsBag;

app(AnalyticsBag::class)->get(); // returns an array of tracked parameters
```

You can also decorate an existing URL with the tracked parameters. This is useful to forward analytics to another domain you're running analytics on.

```

    Buy this product on our webshop

Will link to https://mywebshop.com?utm_source=facebook&utm_campaign=blogpost
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Alex Vanderbist](https://github.com/AlexVanderbist)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1981d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f17d5028e77838cc4a006e046c9e59da9939eacf028f610b56b7d43e218012fa?d=identicon)[vismut](/maintainers/vismut)

---

Top Contributors

[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (9 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (7 commits)")[![vismutx](https://avatars.githubusercontent.com/u/4721671?v=4)](https://github.com/vismutx "vismutx (7 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (2 commits)")

---

Tags

spatielaravel-utm-forwarder

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vismutx-laravel-utm-forwarder/health.svg)

```
[![Health](https://phpackages.com/badges/vismutx-laravel-utm-forwarder/health.svg)](https://phpackages.com/packages/vismutx-laravel-utm-forwarder)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k35.2M958](/packages/spatie-laravel-data)[illuminate/support

The Illuminate Support package.

630113.0M41.1k](/packages/illuminate-support)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[illuminate/collections

The Illuminate Collections package.

27078.0M1.1k](/packages/illuminate-collections)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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