xsuchy09/utm-cookie 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xsuchy09/utm-cookie

Composer 安装命令:

composer require 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.

README 文档

README

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:

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)

Get composer and add this in your requires section of the composer.json:

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

and then

composer install

Usage

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

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

Set name of utm cookie

UtmCookie::setName('utm');

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.

统计信息

  • 总下载量: 58.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固