承接 devlop/utm-parameters 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

devlop/utm-parameters

Composer 安装命令:

composer require devlop/utm-parameters

包简介

Framework agnostic UTM parameters helper

README 文档

README

Latest Stable Version License

UTM Parameters

Framework agnostic (PSR-7 compatible) UTM parameters helper, this tool will simplify working with UTM parameters.

Installation

composer require devlop/utm-parameters

Usage

Capturing incoming UTM parameters

The basic idea is to capture incoming UTM parameters from the query and store them in cookies for later use until needed.

Create a middleware (or similar) following this logic:

use Devlop\UtmParameters\UtmParameters;

// Capture incoming UTM parameters from the query
$utmParameters = UtmParameters::capture($request);

if ($utmParameters !== null) {
    // Remember the UTM parameters in cookies for 30 days
    $utmParameters->remember($response, 30);
}

Retrieving stored UTM parameters

Later when you need the stored UTM parameters (example, after a registration or a placed order) you can easiliy retrieve them.

use Devlop\UtmParameters\UtmParameters;

// Retrieve stored UTM parameters from cookies
$utmParameters = UtmParameters::retrieve($request);

if ($utmParameters !== null) {
    // do something with the UTM parameters
    // optionally forget the cookies
    $utmParameters->forget($response);
}

Available methods

The Devlop\UtmParameters\UtmParameters have the following methods available:

public function getSource() : string

Get the utm_source parameter.

public function getMedium() : ?string

Get the utm_medium parameter.

public function getCampaign() : ?string

Get the utm_campaign parameter.

public function getTerm() : ?string

Get the utm_term parameter.

public function getContent() : ?string

Get the utm_content parameter.

public function toArray() : array

Get all parameters as an array:

[
    "utm_source" => "github",
    "utm_medium" => "email",
    "utm_campaign" => "hackathon_2021",
    "utm_term" => null,
    "utm_content" => null,
]

Iterating

UtmParameters is iterable:

foreach ($utmParameters as $parameter => $value) {
    // ...
}

Constants

All parameter keys are available as constants on UtmParameters to avoid the need to hardcode any parameter keys in your code.

$parameters = $utmParameters->toArray();

$parameters[UtmParameters::SOURCE];
$parameters[UtmParameters::MEDIUM];
$parameters[UtmParameters::CAMPAIGN];
$parameters[UtmParameters::TERM];
$parameters[UtmParameters::CONTENT];

Supported requests / responses

When capturing / retrieving UTM parameters these requests are supported.

When remembering / forgetting UTM parameters these responses are supported.

Laravel

Cookies Facade

The easiest way to remember or forget stored UTM parameters in Laravel is to use the global cookie() helper method to get an instance of QueueingFactory to attach the cookies to the response.

Middleware

utm-parameters ships with a middleware for Laravel for you to use.

Add the middleware in app/Http/Kernel.php, the middleware will automatically capture any incoming UTM parameters and store them in cookies for 30 days.

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            // other configured middleware
            \Devlop\UtmParameters\Laravel\StoreUtmParametersInCookies::class,
        ],
    ];
}

devlop/utm-parameters 适用场景与选型建议

devlop/utm-parameters 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 244 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「psr-7」 「utm-parameters」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 devlop/utm-parameters 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 devlop/utm-parameters 我们能提供哪些服务?
定制开发 / 二次开发

基于 devlop/utm-parameters 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-09