dev-master
9999999-devSnowplow Refer(r)er parser for PHP
MIT
The Development Requires
- php >=5.3.0
- phpunit/phpunit 3.*
- symfony/yaml *
by Yuehlin Chung
Wallogit.com
2017 © Pedro Peláez
Snowplow Refer(r)er parser for PHP
referer-parser is a multi-language library for extracting marketing attribution data (such as search terms) from referer URLs, inspired by the ua-parser project (an equivalent library for user agent parsing)., (*2)
referer-parser is a core component of Snowplow, the open-source web-scale analytics platform powered by Hadoop and Redshift., (*3)
Note that we always use the original HTTP misspelling of 'referer' (and thus 'referal') in this project - never 'referrer'., (*4)
referers.yml: Snowplow Analytics
The PHP version of this library uses the updated API, and identifies search, social, webmail, internal and unknown referers:, (*5)
use Snowplow\RefererParser\Parser;
$parser = new Parser();
$referer = $parser->parse(
'http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari',
'http:/www.psychicbazaar.com/shop'
);
if ($referer->isKnown()) {
echo $referer->getMedium(); // "Search"
echo $referer->getSource(); // "Google"
echo $referer->getTerm(); // "gateway oracle cards denise linn"
}
For more information, please see the PHP README., (*6)
referer-parser identifies whether a URL is a known referer or not by checking it against the referers.yml file; the intention is that this YAML file is reusable as-is by every language-specific implementation of referer-parser., (*7)
The file is broken out into sections for the different mediums that we support:, (*8)
unknown for when we know the source, but not the mediumemail for webmail providerssocial for social media servicessearch for search enginesThen within each section, we list each known provider (aka source) by name, and then which domains each provider uses. For search engines, we also list the parameters used in the search engine URL to identify the search term. For example:, (*9)
Google: # Name of search engine referer
parameters:
- 'q' # First parameter used by Google
- 'p' # Alternative parameter used by Google
domains:
- google.co.uk # One domain used by Google
- google.com # Another domain used by Google
- ...
The number of referers and the domains they use is constantly growing - we need to keep referers.yml up-to-date, and hope that the community will help!, (*10)
We welcome contributions to referer-parser:, (*11)
referers.yml, please fork the repo, add the missing entry and submit a pull requestPlease sign the Snowplow CLA before making pull requests., (*12)
General support for referer-parser is handled by the team at Snowplow Analytics Ltd., (*13)
You can contact the Snowplow Analytics team through any of the channels listed on their wiki., (*14)
referers.yml is based on Piwik's SearchEngines.php and Socials.php, copyright 2012 Matthieu Aubry and available under the GNU General Public License v3., (*15)
The PHP port is copyright 2013-2014 Lars Strojny and is available under the MIT License., (*16)
Snowplow Refer(r)er parser for PHP
MIT