Skip to content

Commit

Permalink
Updated matchers and added host in link
Browse files Browse the repository at this point in the history
  • Loading branch information
ashe540 committed Nov 21, 2018
1 parent cb21bfd commit a20de18
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 51 deletions.
112 changes: 81 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,51 +100,101 @@ inbound.referrer.parse(url, referrer, function (err, description) {
## Supported Matchers

### Social
* [Facebook](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/facebook.js)
* [Twitter](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/twitter.js)
* [Google+](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/googlePlus.js)
* [Pinterest](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/pinterest.js)
* [LinkedIn](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/linkedin.js)
* [Me2day](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/me2day.js)
* [Hangouts](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/hangouts.js)
* [Line](https://github.com/segmentio/inbound/tree/master/lib/matchers/social/line.js)
* [Facebook](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/facebook.js)
* [Twitter](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/twitter.js)
* [Google+](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/googlePlus.js)
* [Pinterest](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/pinterest.js)
* [LinkedIn](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/linkedin.js)
* [Me2day](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/me2day.js)
* [Hangouts](https://github.com/ashe540/inbound/tree/master/lib/matchers/social/hangouts.js)

### Search
* [Google](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/google.js)
* [Bing](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/bing.js)
* [Yahoo](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/yahoo.js)
* [Baidu](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/baidu.js)
* [Yandex](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/yandex.js)
* [Naver](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/naver.js)
* [Daum](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/daum.js)
* [Nate](https://github.com/segmentio/inbound/tree/master/lib/matchers/search/nate.js)
* [Google](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/google.js)
* [Bing](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/bing.js)
* [Yahoo](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/yahoo.js)
* [Baidu](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/baidu.js)
* [Yandex](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/yandex.js)
* [Naver](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/naver.js)
* [Daum](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/daum.js)
* [Nate](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/nate.js)
* [360](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/360.js)
* [Alice](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/alice.js)
* [Alltheweb](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/alltheweb.js)
* [Altavista](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/altavista.js)
* [AOL](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/aol.js)
* [Ask](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/ask.js)
* [Auone](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/auone.js)
* [AVG](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/aVG.js)
* [Babylon](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/babylon.js)
* [Baidu](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/baidu.js)
* [Biglobe](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/biglobe.js)
* [Bing](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/bing.js)
* [Centrum](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/centrum.js)
* [CNN](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/cnn.js)
* [Comcast](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/comcast.js)
* [Conduit](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/conduit.js)
* [Daum](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/daum.js)
* [Docomo](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/docomo.js)
* [Eniro](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/eniro.js)
* [Globo](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/globo.js)
* [GoMailRu](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/gomailru.js)
* [Goo.ne](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/goo.ne.js)
* [Incredimail](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/incredimail.js)
* [Kvasir](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/kvasir.js)
* [Lycos](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/lycos.js)
* [Mamma](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/mamma.js)
* [MSN](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/msn.js)
* [Mynet](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/mynet.js)
* [Najdi](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/najdi.js)
* [Naver](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/naver.js)
* [Netscape](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/netscape.js)
* [Onet](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/onet.js)
* [Ozu](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/ozu.js)
* [Rakuten](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/rakuten.js)
* [Rambler](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/rambler.js)
* [Search-results](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/search-results.js)
* [Sesam](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/sesam.js)
* [Seznam](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/seznam.js)
* [So](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/so.js)
* [Sogou](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/sogou.js)
* [Startsiden](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/startsiden.js)
* [Szukacz](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/szukacz.js)
* [Terra](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/terra.js)
* [Tut.by](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/tutby.js)
* [UKR](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/ukr.js)
* [Virgilio](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/virgilio.js)
* [Voila](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/voila.js)
* [Wirtulana-Polska](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/wirtulana-polska.js)
* [Yahoo](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/yahoo.js)
* [Yam](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/yam.js)
* [Yandex](https://github.com/ashe540/inbound/tree/master/lib/matchers/search/yandex.js)

### Email Clients
* [Gmail](https://github.com/segmentio/inbound/tree/master/lib/matchers/email/gmail.js)
* [Yahoo](https://github.com/segmentio/inbound/tree/master/lib/matchers/email/yahoo.js)
* [Hotmail](https://github.com/segmentio/inbound/tree/master/lib/matchers/email/hotmail.js)
* [Naver](https://github.com/segmentio/inbound/tree/master/lib/matchers/email/naver.js)
* [Daum](https://github.com/segmentio/inbound/tree/master/lib/matchers/email/daum.js)
* [Gmail](https://github.com/ashe540/inbound/tree/master/lib/matchers/email/gmail.js)
* [Yahoo](https://github.com/ashe540/inbound/tree/master/lib/matchers/email/yahoo.js)
* [Hotmail](https://github.com/ashe540/inbound/tree/master/lib/matchers/email/hotmail.js)
* [Naver](https://github.com/ashe540/inbound/tree/master/lib/matchers/email/naver.js)
* [Daum](https://github.com/ashe540/inbound/tree/master/lib/matchers/email/daum.js)

### Ads
* [Bing](https://github.com/segmentio/inbound/tree/master/lib/matchers/ad/bing.js)
* [Google](https://github.com/segmentio/inbound/tree/master/lib/matchers/ad/google.js)
* [Yahoo](https://github.com/segmentio/inbound/tree/master/lib/matchers/ad/yahoo.js)
* [Bing](https://github.com/ashe540/inbound/tree/master/lib/matchers/ad/bing.js)
* [Google](https://github.com/ashe540/inbound/tree/master/lib/matchers/ad/google.js)
* [Yahoo](https://github.com/ashe540/inbound/tree/master/lib/matchers/ad/yahoo.js)

### Internal
Internal referrers occur when a visitor navigates between two pages of the same domain. Example: http://site.com => http://site.com/about

* [Internal](https://github.com/segmentio/inbound/tree/master/lib/matchers/internal/internal.js)
* [Internal](https://github.com/ashe540/inbound/tree/master/lib/matchers/internal/internal.js)

### Link
If there is a referrer present but it's unrecognized above, we'll just call it a link referrer.

* [Link](https://github.com/segmentio/inbound/tree/master/lib/matchers/link/link.js)
* [Link](https://github.com/ashe540/inbound/tree/master/lib/matchers/link/link.js)

### Direct
When a visitor navigates to a site by typing in the url into the address bar, ```document.referrer``` is blank. This is called a direct referral. (There are some [other reasons](#why-is-my-documentreferrer-blank) this can happen as well.)

* [Direct](https://github.com/segmentio/inbound/tree/master/lib/matchers/direct/direct.js)
* [Direct](https://github.com/ashe540/inbound/tree/master/lib/matchers/direct/direct.js)

## Utilities

Expand Down Expand Up @@ -179,11 +229,11 @@ Matchers help identify and attach more semantic information to referral sources.

To add matchers:

1. Using existing matchers as an example, create your matcher at [/lib/matchers/](https://github.com/segmentio/inbound/tree/master/lib/matchers/).
1. Add your matcher to the priority list of matchers in [index.js](https://github.com/segmentio/inbound/tree/master/lib/matchers/index.js).
1. Add your test cases to [the test cases file](https://github.com/segmentio/inbound/tree/master/test/cases/referrers.json).
1. Using existing matchers as an example, create your matcher at [/lib/matchers/](https://github.com/ashe540/inbound/tree/master/lib/matchers/).
1. Add your matcher to the priority list of matchers in [index.js](https://github.com/ashe540/inbound/tree/master/lib/matchers/index.js).
1. Add your test cases to [the test cases file](https://github.com/ashe540/inbound/tree/master/test/cases/referrers.json).
1. Run and confirm that your test cases pass: ```npm test```
1. Add your matcher to the [readme](https://github.com/segmentio/inbound/tree/master/README.md).
1. Add your matcher to the [readme](https://github.com/ashe540/inbound/tree/master/README.md).
1. Submit your pull request!

## Advanced
Expand Down
12 changes: 7 additions & 5 deletions lib/matchers/ad/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ var querystring = require('querystring');

module.exports = function (href, referrer, callback) {

if (referrer.host && referrer.href && referrer.path &&
(referrer.host.indexOf('google') !== -1 || referrer.host.indexOf('googleadservices.com') !== -1)
&& (referrer.href.indexOf('?gclid') !== -1 || referrer.path.indexOf("/aclk") !== -1)) {

if (referrer.host &&
referrer.path &&
referrer.path.indexOf("/aclk") !== -1 &&
(referrer.host.indexOf('google') !== -1 ||
referrer.host.indexOf('googleadservices.com') !== -1)) {

var description = {
type: 'ad',
network: 'google'
};
var query = querystring.parse(referrer.query).q;
if (query) description.query = query;

return callback(null, description);
} else {
return callback(null, false);
Expand Down
1 change: 0 additions & 1 deletion lib/matchers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = [
require('./social/pinterest'),
require('./social/twitter'),
require('./social/me2day'),
require('./social/line'),
require('./social/hangouts'),

require('./search/360'),
Expand Down
3 changes: 2 additions & 1 deletion lib/matchers/link/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = function (href, referrer, callback) {
return callback(null, {
type: 'link',
from: referrer.href,
link: href.href
link: href.href,
host: referrer.host
});
} else {
return callback(null, false);
Expand Down
4 changes: 2 additions & 2 deletions lib/matchers/search/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = function (href, referrer, callback) {

if (referrer.host && referrer.href &&
referrer.host.indexOf('google') !== -1 &&
(referrer.href.indexOf('/url?') !== -1 ||
referrer.href.indexOf('/search?') !== -1)) {
(referrer.href.indexOf('/url?') !== -1 || referrer.href.indexOf('/url/?') !== -1 ||
referrer.href.indexOf('/search?') !== -1 || referrer.href.indexOf('/search/?') !== -1)) {

var description = { type: 'search', engine: 'google' };
var query = querystring.parse(referrer.query).q;
Expand Down
11 changes: 0 additions & 11 deletions lib/matchers/social/line.js

This file was deleted.

0 comments on commit a20de18

Please sign in to comment.