tattali / utm-cookie-bundle
This bundle allow you to save utm parameters from url into a cookie when they exists. It's also provide a bunch of tools to easily retrive all or each utm.
Package info
github.com/tattali/UtmCookieBundle
Type:symfony-bundle
pkg:composer/tattali/utm-cookie-bundle
Requires
- php: >=8.4
- symfony/config: ^8.0
- symfony/dependency-injection: ^8.0
- symfony/http-foundation: ^8.0
- symfony/http-kernel: ^8.0
- symfony/polyfill-ctype: ^1.8
- symfony/service-contracts: ^2.5 || ^3.0
Requires (Dev)
- ext-filter: *
- friendsofphp/php-cs-fixer: ^3.90
- infection/infection: ^0.35
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.5
- shipmonk/composer-dependency-analyser: ^1.8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v8.1.0
- v8.0.0
- 7.x-dev
- v7.1.0
- v7.0.0
- 6.x-dev
- v6.1.0
- v6.0.0
- 5.x-dev
- v5.0.0
- v1.1.0
- v1.0
- dev-check-dependencies-on-main
- dev-mutation-tests-on-main
- dev-phpstan-max-level-on-main
- dev-ci-every-php-and-symfony-8-minor-on-main
- dev-regenerate-ci-with-no-blocking-on-7.x
- dev-regenerate-ci-with-no-blocking-on-6.x
- dev-regenerate-ci-with-no-blocking-on-5.x
- dev-check-dependencies-on-7.x
- dev-mutation-tests-on-7.x
- dev-phpstan-max-level-on-7.x
- dev-ci-every-php-and-symfony-minor-on-7.x
- dev-ci-proof-unmaintained-symfony-minors-on-7.x
- dev-check-dependencies-on-6.x
- dev-mutation-tests-on-6.x
- dev-phpstan-max-level-on-6.x
- dev-check-dependencies-on-5.x
- dev-mutation-tests-on-5.x
- dev-phpstan-max-level-on-5.x
- dev-ci-every-php-on-6.x
- dev-ci-every-php-on-5.x
- dev-replace-deprecated-sanitize-filter-5.x
- dev-replace-deprecated-sanitize-filter-6.x
- dev-forget-utm-values-on-clear-7.x
- dev-forget-utm-values-on-clear-6.x
- dev-support-only-symfony-5-4
- dev-support-only-symfony-6-4
- dev-support-only-symfony-7
- dev-support-only-symfony-8
- dev-replace-phpcs-with-php-cs-fixer
- dev-show-badges-under-the-title
- dev-use-shared-readme-badges
- dev-analyse-code-with-sonarcloud
- dev-align-ci-with-other-bundles
This package is auto-updated.
Last update: 2026-10-18 22:24:22 UTC
README
This bundle allow you to save utm parameters from url into a cookie when they exists. It's also provide a bunch of tools to easily retrive all or each utm.
Each major version of the bundle supports one Symfony major version. Require the version that matches your Symfony version:
| Bundle | Symfony | PHP | Install | Branch | Maintenance |
|---|---|---|---|---|---|
| 8.x | 8.x | 8.4+ | composer require tattali/utm-cookie-bundle |
main |
new features |
| 7.x | 7.x | 8.2+ | composer require tattali/utm-cookie-bundle:^7.1 |
7.x |
bug fixes |
| 6.x | 6.4 | 8.1+ | composer require tattali/utm-cookie-bundle:^6.1 |
6.x |
bug fixes |
| 5.x | 5.4 | 7.2.5+ | composer require tattali/utm-cookie-bundle:^5.0 |
5.x |
security fixes only |
The version constraint matters: 7.0.0 and 8.0.0 also allow Symfony 6.4 and 7, and 6.0.0 allows Symfony 5, so without it Composer can install a version that is not made for your Symfony version.
For Symfony 3.4 to 5.3, use tattali/utm-cookie-bundle:^1.1. See the changelog when upgrading.
Documentation
Installation
On Symfony 8:
$ composer require tattali/utm-cookie-bundle
For an older Symfony version, use the command from the table above.
Usage
<?php use UtmCookieBundle\UtmCookie\UtmCookie; class ExampleHandler { public function __construct( private readonly UtmCookie $utmCookie, ) { } public function example() { $this->utmCookie->get(); // get all utm cookies as array } }
Get all values as array
$this->utmCookie->get();
Get each values
$this->utmCookie->get('utm_campaign'); // or whithout 'utm_' prefix $this->utmCookie->get('utm_content'); $this->utmCookie->get('utm_medium'); $this->utmCookie->get('utm_source'); $this->utmCookie->get('utm_term');
Initialize
Only if auto_init parameter is FALSE else it will be automatically initialized
$this->utmCookie->init(); // Init and read utm params and cookie and save new values.
The cookie is added to the response of the current request.
Parameters (optional):
utm_cookie: auto_init: true # Automaticaly run init when get method is called domain: '' # The (sub)domain that the cookie is available to, or '' to use current domain httponly: false # When TRUE the cookie will be made accessible only through the HTTP protocol lifetime: 604800 # The lifetime of the cookie in seconds (default 604800 => 7 days) name: 'utm' # The name of the cookie (default value "utm") overwrite: true # If overwrite all utm values when even one is set in get path: '/' # The path on the server in which the cookie will be available on samesite: 'lax' # The SameSite attribute: 'lax', 'strict', 'none', or null to leave it out secure: null # null: secure when the request is made over HTTPS; true or false to force it
Cookie flags
samesitedefaults tolax, so the cookie is sent when a visitor follows a link to your site but not on cross-site subrequests. Browsers ignoresamesite: 'none'unless the cookie is also secure.securedefaults tonull: the cookie gets the Secure flag when the current request is made over HTTPS. Behind a reverse proxy that terminates TLS, configure Symfony's trusted proxies so the request is seen as HTTPS. Settrueorfalseto force the flag.httponlydefaults tofalseso that front-end JavaScript can read the utm values. Set it totrueif only the server reads them.
License
This bundle is under the MIT license.