-
-
Notifications
You must be signed in to change notification settings - Fork 2
Usage via Facade or Helper Class
The Laravel UTM-Parameters package offers flexible options for integrating and utilizing UTM parameters within your Laravel application. You can access UTM parameters either through the provided Facade or via Helper functions, depending on your preference and coding style.
The Facade provides a convenient way to interact with the UTM parameters throughout your application. By leveraging the Facade, you can easily retrieve, check, and utilize UTM parameters in your controllers, views, middleware, and other parts of your Laravel application.
Here's an example of how you can use the Facade to check for the presence of a specific UTM parameter and perform actions accordingly:
use Suarez\UtmParameter\Facades\UtmParameter;
if (UtmParameter::has('campaign', 'special-sale')) {
return redirect('/special-offer');
}
In this example, the UtmParameter Facade is used to check if the UTM parameter campaign has the value special-sale. If it does, the user is redirected to a special offer page.
Alternatively, you can utilize the Helper functions provided by the Laravel UTM-Parameters package to work with UTM parameters. These Helper functions offer a more concise syntax and can be directly used within your views, controllers, routes, and other parts of your Laravel application.
Here's how you can use the Helper functions to achieve the same result as the previous example:
if (has_utm('campaign', 'special-sale')) {
return redirect('/special-offer');
}
In this code snippet, the has_utm Helper function is used to check if the UTM parameter campaign has the value special-sale, and if true, a redirect to a special offer page is performed.
Whether you prefer using the Facade or the Helper functions, the Laravel UTM-Parameters package offers convenient methods for working with UTM parameters in your Laravel application. Choose the approach that best suits your coding style and requirements, and leverage UTM parameters to enhance the functionality and customization of your application.