Skip to content

Commit

Permalink
Merge branch 'main' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-suarez authored Jun 19, 2024
2 parents b3037cc + a4a22e2 commit c7f1218
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Laravel UTM-Parameters

[![Latest Version on Packagist](https://img.shields.io/packagist/v/suarez/laravel-utm-parameter.svg?style=flat-square)](https://packagist.org/packages/suarez/laravel-utm-parameter)
[![StyleCI](https://github.styleci.io/repos/448347178/shield?branch=main)](https://github.styleci.io/repos/448347178?branch=main)
[![Test PHP 8.x](https://github.com/toni-suarez/laravel-utm-parameter/actions/workflows/tests-php8.yml/badge.svg?branch=main)](https://github.com/toni-suarez/laravel-utm-parameter/actions/workflows/tests-php8.yml)
[![Packagist Downloads](https://img.shields.io/packagist/dt/suarez/laravel-utm-parameter)](https://packagist.org/packages/suarez/laravel-utm-parameter)
Expand All @@ -17,39 +18,19 @@ A lightweight way to handle UTM parameters session-based in your Laravel Applica

---

## Table of Content

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## Introduction

What are these UTM parameters? UTM is an acronym standing for "Urchin Tracking Module" and where initially introduced in Google Analytics. It's a way, mostly marketers track effectiveness of online marketing campaigns.

There are five different UTM parameters:
- utm_source
- utm_medium
- utm_campaign
- utm_content
- utm_term

Not all parameters are used everytime.
Here would be a common example: https://www.example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=holiday-sale


## Installation

Install the `utm-parameter` package with composer:
Follow these steps to install the Laravel UTM-Parameters package. [Guide for Laravel 10 and below.](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Installation-Guide-(Laravel-8.x-to-10.x))

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

```bash
$ composer require suarez/laravel-utm-parameter
```

### Middleware
### Middleware Configuration

Open the `bootstrap/app.php` file and append the `UtmParameters::class` inside the web-group
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.

```php
# Laravel 11
Expand All @@ -64,7 +45,10 @@ return Application::configure(basePath: dirname(__DIR__))
...
```

To enable UTM-Parameters only for certain requests to your site, add a new alias.
### Middleware Alias (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 bootstrap/app.php file and append the `UtmParameters::class` inside the web-group.


```php
# Laravel 11
Expand All @@ -87,20 +71,20 @@ To apply UTM-Parameters to specific routes, use the following middleware: `utm-p

```php
Route::middleware('utm-parameters')
->get('langing-page/{slug}', 'LandingPageController@show');
->get('landing-page/{slug}', 'LandingPageController@show');
```

## Usage

### All UTM parameters
### get_all_utm()

To get an array of all UTM parameters, use this helper: `get_all_utm()`.

```php
$parameter = get_all_utm();
```

### Get UTM parameter
### get_utm()

If you need to retrieve certain UTM parameters, use `get_utm('source|medium|campaign|term|content')`.

Expand Down Expand Up @@ -130,7 +114,7 @@ Route::get('/', function () {
});
```

### Has UTM parameter
### has_utm()

Sometimes you want to show or do something, if user might have some or specific utm-parameters.

Expand Down Expand Up @@ -158,6 +142,26 @@ Simply use:
}
```


## Resources
Explore additional use cases and resources on the [wiki pages](https://github.com/toni-suarez/laravel-utm-parameter/wiki)

- [Installation Guide](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Installation-Guide)
- [Installation Guide (Laravel 8.x to 10.x)](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Installation-Guide-(Laravel-8.x-to-10.x))
- [How it works](https://github.com/toni-suarez/laravel-utm-parameter/wiki/How-it-works)
- [Limitations](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Limitations)
- [Advanced Usage](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Advanced-Usage)
- [Blade Usage](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Blade-Usage)
- [Usage via Facade or Helper Class](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Usage-via-Facade-or-Helper-Class)

### Inspirations
- [Use Case: A/B Testing](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use-Case:-A-B-Testing)
- [Use Case: Different Styles for Social Media](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use-Case:-Different-Styles-for-Social-Media)
- [Use Case: Lead Attribution](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use-Case:-Lead-Attribution)
- [Use Case: Social Media Tracking](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use-Case:-Social-Media-Tracking)
- [Use‐Case: Newsletter Redirect on Product Detail Page](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use%E2%80%90Case:-Newsletter-Redirect-on-Product-Detail-Page)
- [Use‐Case: Offline Marketing Integration](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Use%E2%80%90Case:-Offline-Marketing-Integration)

---

## License
Expand Down

0 comments on commit c7f1218

Please sign in to comment.