Permalink
Browse files

add save cookie

  • Loading branch information...
1 parent ef335b1 commit 4b0f2d226a350bdd7825ed8b69cb49c179ae2229 @jacquescrocker committed Jun 2, 2011
Showing with 11 additions and 0 deletions.
  1. +1 −0 README.md
  2. +1 −0 lib/aarrr/config.rb
  3. +9 −0 lib/aarrr/session.rb
View
@@ -58,6 +58,7 @@ You can get a session in a few different ways:
# pass in the tracking code directly
AARRR(cookies["_utmarrr"])
+You should then save the session to cookie: `AARRR(request.env).save(response)`
### Tracking vs Completion events
View
@@ -31,6 +31,7 @@ def option(name, options = {})
# default some options with defaults
option :database_name, :default => "metrics"
option :cookie_name, :default => "_utmarr"
+ option :cookie_expiration, :default => 60*24*60*60
option :user_collection_name, :default => "aarrr_users"
option :event_collection_name, :default => "aarrr_events"
@@ -46,6 +46,15 @@ def track!(event_name, options = {})
})
end
+ # save a cookie to the response
+ def save(response)
+ response.set_cookie(AARRR::Config.cookie_name, {
+ :value => self.id,
+ :path => "/",
+ :expires => Time.now+AARRR::Config.cookie_expiration
+ })
+ end
+
protected
# mark update

0 comments on commit 4b0f2d2

Please sign in to comment.