tattali/utm-cookie-bundle

此扩展允许您在URL中存在时,将utm参数保存到cookie中。它还提供了一系列工具,方便您检索所有或单个utm参数。

安装次数: 15,412

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 6

公开问题: 3

类型:symfony-bundle

v1.1.0 2020-04-06 13:30 UTC

This package is auto-updated.

Last update: 2024-09-24 19:11:45 UTC


README

此扩展允许您在URL中存在时,将utm参数保存到cookie中。它还提供了一系列工具,方便您检索所有或单个utm参数。

  • Symfony 3.4+ 或 Symfony 4.0+ 或 Symfony 5.0+
  • PHP v7.1+

文档

安装

$ composer require tattali/utm-cookie-bundle

使用方法

<?php

use UtmCookieBundle\UtmCookie\UtmCookie;

class ExampleHandler
{
    private $utmCookie;

    public function __construct(UtmCookie $utmCookie) {
        $this->utmCookie = $utmCookie;
    }

    public function example()
    {
        $this->utmCookie->get(); // get all utm cookies as array
    }
}

获取所有值作为数组

$this->utmCookie->get();

获取每个值

$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');

初始化

仅当auto_init参数为FALSE时才初始化,否则将自动初始化

$this->utmCookie->init(); // Init and read utm params and cookie and save new values.

参数(可选)

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
    secure: false     # Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client

许可证

此扩展遵循MIT许可证。