Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelligently parse referrers so they're easier to glance at #8

Closed
bamos opened this issue May 14, 2015 · 6 comments
Closed

Intelligently parse referrers so they're easier to glance at #8

bamos opened this issue May 14, 2015 · 6 comments

Comments

@bamos
Copy link
Owner

bamos commented May 14, 2015

Example:

  • http://www.google.com/url?cmVhbGx5IGxvbmcgc3RyaW5nIHRvIGluZGljYXRlIGEgc2VjdXJlIHNlYXJjaA== toGoogle (secure search)`
@alexanderdean
Copy link

Can't you use the existing extracted referer fields from the RefererParserEnrichmentt?

@bamos
Copy link
Owner Author

bamos commented May 16, 2015

Hi @alexanderdean - thanks!
I can use refrUrlhost and parse q=... out of refrUrlquery

Bing

pageReferrer = "http://www.bing.com/search?q=search+query&a=results&MID=2500", pageUrlscheme = "http", pageUrlhost = "bamos.github.io", pageUrlport = Just 80, pageUrlpath = "/XXXX", pageUrlquery = "", pageUrlfragment = "", refrUrlscheme = "http", refrUrlhost = "www.bing.com", refrUrlport = Just 80, refrUrlpath = "/search", refrUrlquery = "q=search+query&a=results&MID=2500", refrUrlfragment = "", refrMedium = "", refrSource = "", refrTerm = ""

Google

pageReferrer = "http://www.google.com/search?site=&source=hp&ei=...&q=search+query&oq=...&gs_l=...&q=search+query", pageUrlscheme = "http", pageUrlhost = "bamos.github.io", pageUrlport = Just 80, pageUrlpath = "/XXXX/", pageUrlquery = "", pageUrlfragment = "", refrUrlscheme = "http", refrUrlhost = "www.google.com", refrUrlport = Just 80, refrUrlpath = "/search", refrUrlquery = "site=&source=hp&ei=...&q=search+query&...", refrUrlfragment = "tbs=qdr:y&q=search+query", refrMedium = "", refrSource = "", refrTerm = ""

@alexanderdean
Copy link

scala> val refererUrl = "http://www.bing.com/search?q=search+query&a=results&MID=2500"
refererUrl: java.lang.String = http://www.bing.com/search?q=search+query&a=results&MID=2500

scala> val pageUrl    = "http://random"
pageUrl: java.lang.String = http://random

scala> import com.snowplowanalytics.refererparser.scala.Parser
import com.snowplowanalytics.refererparser.scala.Parser

scala> for (r <- Parser.parse(refererUrl, pageUrl)) {
     |   println(r.medium)
     |   for (s <- r.source) {
     |     println(s)
     |   }
     |   for (t <- r.term) {
     |     println(t)
     |   }
     | }
search
Bing
search query

Therefore I think your RefererParserEnrichment inside your Kinesis Enrich isn't correctly configured.

@bamos
Copy link
Owner Author

bamos commented May 16, 2015

I see - thanks! Great info.

bamos pushed a commit that referenced this issue May 20, 2015
bamos pushed a commit that referenced this issue May 20, 2015
bamos pushed a commit that referenced this issue May 20, 2015
@bamos
Copy link
Owner Author

bamos commented May 20, 2015

@alexanderdean - the latest snowplow's referrer enrichments are also working great.
Leaving this issue open so I can perfect my prettyReferrer function as
I look at new events with the new enrichments.

prettyReferrer:: EnrichedEvent -> Maybe String
prettyReferrer e =
    case (pageReferrer e, refrMedium e, refrSource e, refrTerm e) of
      ("", _, _, _) -> Nothing
      (url, "search", "", term) -> Just $ url ++ " [TODO: prettyReferrer: \
                                                 \empty refrSource?]"
      (url, "search", source, "") -> Just $ source ++ " [Secure Search]"
      (url, "search", source, term) -> Just $ concat [source, " Search - ", term]
      (url, med, source, term) -> Just $ "TODO: prettyReferrer: " ++
                                    intercalate " - " [url, med, source, term]

@alexanderdean
Copy link

Ah, great to hear it!

@bamos bamos closed this as completed Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants