PHPackages                             xsuchy09/utm-cookie - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xsuchy09/utm-cookie

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xsuchy09/utm-cookie
===================

Utm-Cookie saves utm parameters from url into cookie with defined lifetime (default 7 days). Than cookie (utm) can be used later without parsing google or any other cookies.

2.0.5(1y ago)1456.1k↓38.7%42Apache-2.0PHPPHP &gt;=7.1

Since Jun 6Pushed 1y ago3 watchersCompare

[ Source](https://github.com/xsuchy09/utm-cookie)[ Packagist](https://packagist.org/packages/xsuchy09/utm-cookie)[ Docs](https://github.com/xsuchy09/utm-cookie)[ RSS](/packages/xsuchy09-utm-cookie/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (15)Used By (2)

UtmCookie
=========

[](#utmcookie)

PHP library to save utm parameters from url into cookie for later use. PHP 7.1 is required for version 2.0.0+. If you need PHP 5.4+ compatibility use 1.0.6 version.

Authors:

- Petr Suchy (xsuchy09 - [www.wamos.cz](http://www.wamos.cz))

Overview
--------

[](#overview)

UtmCookie saves utm parameters from url into cookie with defined lifetime (default 7 days). Than cookie (utm) can be used later without parsing google or any other cookies.

It handles utm parameters:

- utm\_campaign
- utm\_medium
- utm\_source
- utm\_term
- utm\_content

You can get them with original name or wihout "utm\_" (for example just "source" for "utm\_source" - you can use both) - see examples.

Since version 2.0.2 you can rewrite these cookies just with call `UtmCookie::save($array)` where `$array` should contains keys allowed by `UtmCookie::$allowedUtmCookieKeys` (default are allowed utm parameters names).

Installation (via composer)
---------------------------

[](#installation-via-composer)

[Get composer](http://getcomposer.org/doc/00-intro.md) and add this in your requires section of the composer.json:

```
{
    "require": {
        "xsuchy09/utm-cookie": "*"
    }
}

```

and then

```
composer install

```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
UtmCookie::init(); // just init - read utm params and cookie and save new values (is auto called by first call of UtmCookie::get method)
UtmCookie::get(); // get all utm cookies as array
UtmCookie::getObject(); // get all utm cookies as object (stdClass)
UtmCookie::get('utm_source'); // get utm_source
UtmCookie::get('source'); // get utm_source
```

### Set lifetime of utm cookie

[](#set-lifetime-of-utm-cookie)

```
$dateInterval = DateInterval::createFromDateString('7 days');
UtmCookie::setLifetime($dateInterval);
```

### Set name of utm cookie

[](#set-name-of-utm-cookie)

```
UtmCookie::setName('utm');
```

### Set if overwrite all utm values even if only one detected.

[](#set-if-overwrite-all-utm-values-even-if-only-one-detected)

Default TRUE. If set to false, utm value is overwite only if set (others will stay).

```
UtmCookie::setOverwrite(false);
```

More examples can be found in the examples/ directory.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~235 days

Recently: every ~572 days

Total

14

Last Release

576d ago

Major Versions

0.0.2 → 1.0.02016-06-06

1.0.6 → 2.0.02018-07-11

PHP version history (3 changes)0.0.1PHP &gt;=5.4 || &gt;=7.0

1.0.0PHP &gt;=5.4

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfb9263df3f7fbc25d3d7645fc4a68878972f9e6e0056e12820a491c1f2b4a64?d=identicon)[xsuchy09](/maintainers/xsuchy09)

---

Top Contributors

[![xsuchy09](https://avatars.githubusercontent.com/u/1107359?v=4)](https://github.com/xsuchy09 "xsuchy09 (31 commits)")[![rshkabko](https://avatars.githubusercontent.com/u/33148760?v=4)](https://github.com/rshkabko "rshkabko (1 commits)")

---

Tags

cookieanalyticsUTM

### Embed Badge

![Health badge](/badges/xsuchy09-utm-cookie/health.svg)

```
[![Health](https://phpackages.com/badges/xsuchy09-utm-cookie/health.svg)](https://phpackages.com/packages/xsuchy09-utm-cookie)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

1.5k4.7M20](/packages/spatie-laravel-cookie-consent)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[segmentio/analytics-php

Segment Analytics PHP Library

25621.5M25](/packages/segmentio-analytics-php)[panphp/pan

A simple, lightweight, and privacy-focused product analytics php package.

1.2k94.6k5](/packages/panphp-pan)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
