Skip to content

Commit

Permalink
add save cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Crocker committed Jun 2, 2011
1 parent ef335b1 commit 4b0f2d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions lib/aarrr/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
9 changes: 9 additions & 0 deletions lib/aarrr/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b0f2d2

Please sign in to comment.