-
-
Notifications
You must be signed in to change notification settings - Fork 2
Installation Guide
Before installing the package, ensure that you have the following prerequisites:
- Laravel framework installed (version 11.x)
- Composer globally installed on your system
Follow these steps to install the Laravel UTM-Parameters package:
Open your terminal and navigate to your Laravel project directory. Then, use Composer to install the package:
$ composer require suarez/laravel-utm-parameter
Once the package is installed, you need to add the UtmParameters middleware to your Laravel application.
Open the bootstrap/app.php
file and append the UtmParameters::class
inside the web-group.
return Application::configure(basePath: dirname(__DIR__))
...
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
Suarez\UtmParameter\Middleware\UtmParameters::class,
/* ... keep the existing middleware here */
]);
})
...
To enable UTM-Parameters only for certain requests or routes in your application, you can add an alias for the UtmParameters middleware.
Open the bootstrap/app.php
file and append the UtmParameters::class
inside the web-group.
use Suarez\UtmParameter\Middleware\UtmParameters;
->withMiddleware(function (Middleware $middleware) {
$middleware
->alias([
/* ... keep the existing mappings here */
'utm-parameters' => UtmParameters::class,
])
->web(append: [
/* ... keep the existing mappings here */
UtmParameters::class
]);
})
To apply UTM-Parameters to specific routes, use the following middleware: utm-parameters
Route::middleware('utm-parameters')->get('landing-page/{slug}', 'LandingPageController@show');
You can now start using the UTM-Parameters package in your Laravel application. Refer to the package documentation for information on how to retrieve and utilize UTM parameters in your controllers, views, or other parts of your application.
Congratulations! You have successfully installed the Laravel UTM-Parameters package in your Laravel application. You can now start tracking and managing UTM parameters in your application to enhance user experience.