laravel-referer

This Laravel package remembers a visitor's original referrer in session data, prioritizing UTM source and referring domain.

github.com/spatie/laravel-referer
laravel-referer homepage screenshot

About laravel-referer

laravel-referer is a Laravel package that stores a visitor's original referer in session data. It checks the utm_source query parameter first, then the domain from the request's Referer header when the host is external, otherwise it stores an empty value. It works by adding the CaptureReferer middleware to the web stack after StartSession. The stored value can be retrieved, manually set, or cleared, and the session key and detection sources can be changed in configuration.

Key features

  • Stores original referer in session via CaptureReferer middleware
  • Prioritizes utm_source query parameter for referer detection
  • Falls back to external domain from Referer request header
  • Retrieves stored referer through container or automatic facades
  • Provides put and forget methods to set or clear referer
  • Supports custom sources implementing the Source interface
Best for: Laravel developers who need to keep a visitor's original referer available during a session.
Good for
  • Empty values do not overwrite an existing stored referer
  • Internal hosts are ignored so site navigation does not change referer
  • Session key and detection sources can be configured
Watch out for
  • Requires adding CaptureReferer middleware after StartSession
  • Default detection is limited to utm_source and external Referer header
  • Config file must be published to change session key or sources

laravel-referer at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Yes · Source code
Language
English
Last checked
Oct 5, 2026 · Online when checked
Listed
Oct 5, 2026

laravel-referer alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in SEO & Web Analytics

Well-known listings from the same topic.

All 211

laravel-referer FAQ

How does the package determine the referer?
It uses the utm_source query parameter first, then the domain from the Referer header if the host is external, otherwise empty.
How do I start capturing the referer?
Add the Spatie\Referer\CaptureReferer middleware to the web middleware group after Laravel's StartSession middleware.
How can I retrieve, set, or clear the stored referer?
Use Referer::get() to retrieve the value, Referer::put('google.com') to set it manually, and Referer::forget() to clear it.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing