Download the PHP package elegantly/laravel-referrer without Composer
On this page you can find all versions of the php package elegantly/laravel-referrer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elegantly/laravel-referrer
More information about elegantly/laravel-referrer
Files in elegantly/laravel-referrer
Package laravel-referrer
Short Description Remember User Origin
License MIT
Homepage https://github.com/elegantengineeringtech/laravel-referrer
Informations about the package laravel-referrer
Remember the Visitor Referrer Across Requests
This package allows you to detect and store visitor referrers so that you can access them later. A typical use case would be saving the referrer in a database when a visitor registers in your app.
Out of the box, it captures:
- Google Click ID (gclid)
- Meta Click ID (fbclid)
- TikTok Click ID (ttclid)
- Header referrer value
- All URL UTM values
- Or add your own source
The package is designed to be highly flexible regarding:
- How you want to detect the referrer
- How you want to store the referrer value
Out of the box, it can store referrer values in:
- Laravel Context
- Laravel Session
- A Cookie
- Or add your own driver
Installation
You can install the package via Composer:
Usage
First, publish the config file with:
Configuration
Then configure your sources and drivers:
In the configuration file, enable one or more drivers by uncommenting them.
Middleware Configuration
Next, add the CaptureReferrerMiddleware
to your route:
Once configured, your referrer sources will be automatically captured.
Choosing a Strategy
What happens when a user encounters multiple referrers during their navigation? For example, a user might click on multiple Google Ads campaigns or links with different UTM parameters.
This package supports 3 capture strategies:
- First: Only capture the first referrer of each source
- Last: Only capture the last referrer of each source
- All: Capture all referrers
From the config, you can define a strategy globally using:
You can also define the strategy per source like this:
Retrieving the Visitor Referrer
You can retrieve the referrer sources using the facade:
Retrieve the first or last referrer value:
Retrieve the oldest or latest referrer value from any source:
Here is a complete example inside a controller:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy for information on how to report security vulnerabilities.
Credits
- Quentin Gabriele
- All Contributors
License
The MIT License (MIT). Please see the License File for more information.
All versions of laravel-referrer with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0