Home

Awesome

referer-parser .NET library

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.

C#

Usage

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"

Installation

A NuGet Package is available, under package id RefererParser.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright and license

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.