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

ActiveLibrary

guiassemany/laravel-utm-forwarder
=================================

Keeps track of the original UTM parameters

1.0.0(5y ago)0131MITPHPPHP ^7.4

Since Jan 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/guiassemany/laravel-utm-forwarder)[ Packagist](https://packagist.org/packages/guiassemany/laravel-utm-forwarder)[ Docs](https://github.com/guiassemany/laravel-utm-forwarder)[ RSS](/packages/guiassemany-laravel-utm-forwarder/feed)WikiDiscussions main Synced yesterday

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

[![](https://camo.githubusercontent.com/3bb1cf5b51b46be987de581090cd7f3b8022181bc3cf21698a15ecc97ea6bfc9/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f55544d253230466f727761726465722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d677569617373656d616e792532466c61726176656c2d75746d2d666f72776172646572267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4b656570732b747261636b2b6f662b7468652b6f726967696e616c2b55544d2b2532386f722b6f746865722b616e616c79746963732532392b706172616d6574657273266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/3bb1cf5b51b46be987de581090cd7f3b8022181bc3cf21698a15ecc97ea6bfc9/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f55544d253230466f727761726465722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d677569617373656d616e792532466c61726176656c2d75746d2d666f72776172646572267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4b656570732b747261636b2b6f662b7468652b6f726967696e616c2b55544d2b2532386f722b6f746865722b616e616c79746963732532392b706172616d6574657273266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/00a4b7e44415af3c489fcac9cf19c985f1672400415abbb1c615f6c6f7bdc942/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677569617373656d616e792f6c61726176656c2d75746d2d666f727761726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guiassemany/laravel-utm-forwarder)[![Total Downloads](https://camo.githubusercontent.com/79bdd82e96f09adc41318c20f05827d69975bfbe6bf17bd0b2fe53fb4bc63612/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677569617373656d616e792f6c61726176656c2d75746d2d666f727761726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guiassemany/laravel-utm-forwarder)

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.

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

[](#installation)

You can install the package via composer:

```
composer require guiassemany/laravel-utm-forwarder
```

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,
        // ...

        \GuiAssemany\UtmForwarder\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="GuiAssemany\UtmForwarder\UtmForwarderServiceProvider"
```

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 `\GuiAssemany\UtmForwarder\Sources` namespace.
     */
    'tracked_parameters' => [
        [
            'key' => 'utm_source',
            'source' => GuiAssemany\UtmForwarder\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_medium',
            'source' => GuiAssemany\UtmForwarder\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_campaign',
            'source' => GuiAssemany\UtmForwarder\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_term',
            'source' => GuiAssemany\UtmForwarder\Sources\RequestParameter::class,
        ],
        [
            'key' => 'utm_content',
            'source' => GuiAssemany\UtmForwarder\Sources\RequestParameter::class,
        ],
        [
            'key' => 'referer',
            'source' => GuiAssemany\UtmForwarder\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 GuiAssemany\UtmForwarder\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://testing.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.

Credits
-------

[](#credits)

- Package built by spatie and [Alex Vanderbist](https://github.com/AlexVanderbist) and all contributors.
- I've just put it here because I want it to be on packagist and make it available for people who want to use it through composer.

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1929d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/793994?v=4)[Guilherme Assemany](/maintainers/guiassemany)[@guiassemany](https://github.com/guiassemany)

---

Top Contributors

[![guiassemany](https://avatars.githubusercontent.com/u/793994?v=4)](https://github.com/guiassemany "guiassemany (1 commits)")

---

Tags

analyticsforwarderforwardinglaravelsessiontrackerutmlaravel-utm-forwarderguiassemany

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[timokoerber/laravel-one-time-operations

Run operations once after deployment - just like you do it with migrations!

6481.7M11](/packages/timokoerber-laravel-one-time-operations)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[illuminate/process

The Illuminate Process package.

44699.5k65](/packages/illuminate-process)

PHPackages © 2026

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