Download the PHP package webudvikleren/laravel-utm-manager without Composer
On this page you can find all versions of the php package webudvikleren/laravel-utm-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webudvikleren/laravel-utm-manager
More information about webudvikleren/laravel-utm-manager
Files in webudvikleren/laravel-utm-manager
Package laravel-utm-manager
Short Description A simple Laravel package to capture and manage UTM parameters.
License MIT
Informations about the package laravel-utm-manager
Laravel UTM Manager
📈 Simple UTM tracking middleware for Laravel. Capture UTM parameters from the URL and make them easily accessible via session or helper methods. Great for tracking marketing sources across forms, registrations, or orders.
✨ Features
- Middleware to automatically store UTM parameters
- Configurable list of UTM keys
- Store in session (default) or extend for other storage
- Facade for easy access:
Utm::get('utm_source') - Trait for auto-filling UTM data directly on Eloquent models
- Trait for attaching UTM data to a related model (
utmVisit) - Artisan command to generate a migration dynamically
🔧 Installation
Publish the config file:
🚀 Usage
1. Add middleware
You can register the middleware globally or per route:
Or assign it to specific routes:
2. Access UTM data
Use the facade to get stored UTM parameters:
3. Automatically attach UTM data to Eloquent models
Add the HasUtmData trait to your model:
When creating the model, UTM fields will be auto-filled (if present in the session).
4. Store UTM data in a related model
If you want to store UTM data in a separate model (e.g., utm_visits), use the HasUtmRelation trait:
Then define the related model like this:
The related model class and table name are both configurable via config/utm.php.
5. Generate a migration for related UTM data
The package includes an Artisan command to generate a migration based on the configured UTM keys and table name.
This will generate a migration with the correct user_id foreign key and all defined UTM columns.
6. Publish the default UtmVisit model
To create a prebuilt UtmVisit model in your app/Models folder:
`
You can then customize the model or change the class in config/utm.php.
⚙️ Configuration
📦 Example URL
Send traffic with UTM parameters to your app:
https://yourapp.com/register?utm_source=facebook&utm_medium=social&utm_campaign=summer-sale
The package will capture and store these in the user's session.
✅ Roadmap Ideas
- Cookie support
- Database logging
- Integration with Laravel Nova or Horizon
- Debug toolbar for current UTM state