Skip to content

Installation Guide (Laravel 8.x to 10.x)

Toni Suárez Rios edited this page Mar 17, 2024 · 2 revisions

Introduction

The Laravel UTM-Parameters package provides a lightweight way to handle UTM parameters session-based in your Laravel application. This guide will walk you through the installation process step by step.

Prerequisites

Before installing the package, ensure that you have the following prerequisites:

  • Laravel framework installed (version 8.x to 10.x)
  • Composer globally installed on your system

Installation Steps

Follow these steps to install the Laravel UTM-Parameters package:

Step 1: Install Package

Open your terminal and navigate to your Laravel project directory. Then, use Composer to install the package:

composer require suarez/laravel-utm-parameter

Step 2: Middleware Configuration

Once the package is installed, you need to add the UtmParameters middleware to your Laravel application.

Open the app/Http/Kernel.php file and append the UtmParameters middleware to the web group:

use Suarez\UtmParameter\Middleware\UtmParameters;

protected $middlewareGroups = [
    'web' => [
        // Other middleware...
        UtmParameters::class,
    ],
];

Step 3: Alias Configuration (Optional)

To enable UTM-Parameters only for certain requests or routes in your application, you can add an alias for the UtmParameters middleware.

Open the app/Http/Kernel.php file and append the UtmParameters middleware to the web group:

use Suarez\UtmParameter\Middleware\UtmParameters;

protected $middlewareGroups = [
    'web' => [
        // Other middleware...
        'utm-parameters' => UtmParameters::class,
    ],
];

Step 4: Usage

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.

Conclusion

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.