This is the .NET implementation of referer-parser, the library for extracting attribution data from referer (sic) URLs.
The implementation uses the shared 'database' of known referers found in referers.yml
.
The .NET version of referer-parser is maintained by Sepp Wijnands at iPerform Software.
Use referer-parser in C# like this:
using RefererParser;
...
string refererUrl = "http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari";
string pageUrl = "http:/www.psychicbazaar.com/shop"; // Our current URL
var referer = Parser.Parse(new Uri(refererUrl), pageUrl);
Console.WriteLine(r.Medium); // => "Search"
Console.WriteLine(r.Source); // => "Google"
Console.WriteLine(r.Term); // => "gateway oracle cards denise linn"
// usage with custom supplied databases and new Medium Values:
private enum TestEnum
{
// Order is important, most important medium's first
Search = 0,
Paid,
Social,
Email,
Unknown,
Internal,
Foobar
}
referrerUrl = "https://thrivehive.com";
var parser = new Parser<MyEnum>(new[] {@"
foobar:
Thrivehive:
domains:
- thrivehive.com"});
var referer = Parser.Parse(new Uri(refererUrl), pageUrl);
Console.WriteLine(r.Medium); // => "Foobar"
Console.WriteLine(r.Source); // => "Thrivehive"
A NuGet Package is available, under package id RefererParser.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
The referer-parser .NET (C#) library is copyright 2013 iPerform Software.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.