nox-it / yii2-nox-referer-parser
This package is abandoned and no longer maintained.
No replacement package was suggested.
Yii2 Referer Parser
2.0.0
2020-05-03 15:35 UTC
Requires
- php: >=7.4.0
- nox-it/yii2-nox: ~2.0.0
- nox-it/yii2-nox-helpers: ~2.0.0
- nox-it/yii2-nox-mvc: ~2.0.0
- nox-it/yii2-nox-user-agent-parser: ~2.0.0
- snowplow/referer-parser: ~0.2.0
README
NOX 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.