Question

I'd like to track the referrer URL for the first point of contact a user has in my site but only if they sign up. I'm thinking this should be accomplished by caching S.referrer when a new LiftSession is created but how does one invoke code at session creation?

Was it helpful?

Solution

LiftSession has a hook afterSessionCreate which is a list of functions to call after a session is created. At this point SessionVars work so the referer can be stored in one until needed. The following adds a hook in Boot.scala to just display the referer:

LiftSession.afterSessionCreate = ((l: LiftSession, r: Req) => println(S.referer) :: LiftSession.afterSessionCreate
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top