Skip to content

Erlang library for extracting marketing attribution data from referrer URLs

License

Notifications You must be signed in to change notification settings

silviucpp/refererparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a Erlang library for extracting marketing attribution data from referrer URLs based on referer-parser database

Getting started:

Integration

The application is compatible with both rebar or rebar3. Add erluap as a rebar dependency to your project:

{deps, [
  {refererparser, ".*", {git, "https://github.com/silviucpp/refererparser.git", "master"}},
}.
Update database

The latest database of referers can be downloaded from referer-parser repo. This file should replace priv/referers.json. Also it's ok to replace the referer-tests.json as well with the last file once you update the referers database and to rerun the tests in order to check that nothing broken.

API

All available mediums are inside refererparser.hrl as follow:

-define(MEDIUM_UNKNOWN, unknown).
-define(MEDIUM_INTERNAL, internal).
-define(MEDIUM_SEARCH, search).
-define(MEDIUM_SOCIAL, social).
-define(MEDIUM_EMAIL, email).

The referer is returned in a record defined as follow:

-record(referer, {
    medium ::medium(),
    source = null :: ref_source(),
    term = null :: ref_term()
}).

In order to get the referer you can use the parse/2 method where you can specify The referrer URL to parse and the URL of the current page.

refererparser:start().
refererparser:parse(
    <<"http://www.google.com/search?q=gateway+cards&client=safari">>, <<"http://my-web.com">>).
{ok,{referer,search,<<"Google">>, <<"gateway cards">>}}

Tests

In order to run the tests just use make ct from project root after you compiled and got the deps using rebar

About

Erlang library for extracting marketing attribution data from referrer URLs

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published