nyx-solutions/yii2-nyx-referer-parser
Composer 安装命令:
composer require nyx-solutions/yii2-nyx-referer-parser
包简介
Yii2 Referer Parser
README 文档
README
NYX Referer Parser is a PHP library for extracting marketing attribution data (such as search terms) from referer URLs.
Installation
The preferred way to install this extension is through composer.
- Either run
php composer.phar require --prefer-dist "nyx-solutions/yii2-nyx-referer-parser" "*"
or add
"nyx-solutions/yii2-nyx-referer-parser": "*"
to the require section of your application's composer.json file.
Usage
In components (in the following example we get the RefererParser data and pass to the PublicAccessLog model, which in this case is just an example):
namespace common\components\http; use common\models\PublicAccessLog; /** * Class RefererParser * * @package common\components\http */ class RefererParser extends \nyx\components\http\referer\RefererParser { #region Constants const TYPE_GOOGLE_ORGANIC = PublicAccessLog::TYPE_GOOGLE_ORGANIC; const TYPE_GOOGLE_ADS = PublicAccessLog::TYPE_GOOGLE_ADS; const TYPE_GOOGLE_CAMPAIGN = PublicAccessLog::TYPE_GOOGLE_CAMPAIGN; const TYPE_EXTERNAL_SEARCH = PublicAccessLog::TYPE_EXTERNAL_SEARCH; const TYPE_EXTERNAL_SITE = PublicAccessLog::TYPE_EXTERNAL_SITE; const TYPE_DIRECT = PublicAccessLog::TYPE_DIRECT; #endregion }
In the Controller Action:
$refererParser = new RefererParser(); $this->publicAccessLog = new PublicAccessLog(['scenario' => PublicAccessLog::SCENARIO_INSERT]); $this->publicAccessLog->type = $refererParser->getType(); $this->publicAccessLog->description = $refererParser->getDescription(); $this->publicAccessLog->source = $refererParser->getSource(); $this->publicAccessLog->medium = $refererParser->getMedium(); $this->publicAccessLog->term = $refererParser->getTerm(); $this->publicAccessLog->content = $refererParser->getContent(); $this->publicAccessLog->campaign = $refererParser->getCampaign(); $this->publicAccessLog->device = $refererParser->getDevice(); $this->publicAccessLog->save(false);
License
yii2-nyx-referer-parser is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
统计信息
- 总下载量: 86
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-06-01