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

This package is auto-updated.

Last update: 2022-06-01 20:12:01 UTC


README

NOX Referer Parser is a PHP library for extracting marketing attribution data (such as search terms) from referer URLs.

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

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.

Yii2