Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating helpers

  • Loading branch information...
commit 77547e8449ab14e547d86d737f866eec5fd7cbc6 1 parent aaa09d9
@railsjedi authored
Showing with 73 additions and 26 deletions.
  1. +23 −11 README.md
  2. +2 −2 lib/aarrr.rb
  3. +48 −13 lib/aarrr/session.rb
View
34 README.md
@@ -58,11 +58,14 @@ 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)`
+You should then save the session to cookie: `AARRR(request.env).set_cookie(response)`
-### Tracking vs Completion events
-For each category of events, you can track multiple events leading up to the actual "completion" step for a category, use the option `:in_progress => true`
+### Completion events
+
+For each category of events, each events you log leads up to a "completion" step for a category. Once you hit an event that provides a "completion" step, add :complete => true. You can also use the ! version of the method to designate that the funnel has been completed for this action.
+
+ AARRR(request.env).acquisition!(:signed_up) #=> passes along :complete => true
### Acquisition
@@ -75,7 +78,7 @@ If you'd rather define Acquisition events manually, just use:
To track the funnel leading up to the acquisition event, use:
- AARRR(request.env).acquisition!(:opened_signup_popup, :in_progress => true)
+ AARRR(request.env).acquisition(:opened_signup_popup)
### Activation
@@ -113,13 +116,6 @@ Referrals are done in 2 parts. First you can track when someone decides to refer
When someone enters the site without an activated session and a referral code shows up, then we track the referral event as soon as the user signs up.
-### Track
-
-Track allows you to trigger multiple events at a time. (defaults to :activation event)
-
- AARRR(request.env).track!(:built_page, :event_type => :activate, :in_progress => true)
-
-
### Revenue
Whenever you capture a dollar from user, then you should track that intake event.
@@ -134,6 +130,22 @@ Whenever you capture a dollar from user, then you should track that intake event
AARRR(request.env).revenue!(55.00, :unique => "x8175m1o58113")
+### Track
+
+Track allows you to trigger multiple events at a time. (defaults to :activation event)
+
+ AARRR(request.env).track!(:built_page, :event_type => :activate)
+
+
+### Shortened helper aliases
+
+ AARRR.acq #=> same as AARRR.acquisition
+ AARRR.act #=> same as AARRR.activation
+ AARRR.ret #=> same as AARRR.retention
+ AARRR.ref #=> same as AARRR.referral
+ AARRR.rev #=> same as AARRR.revenue
+
+
## Cohorts
Cohorts are ways to slice up reports so you can see the results for these 5 metrics for groups of specific users. Some useful examples are:
View
4 lib/aarrr.rb
@@ -13,11 +13,11 @@
end
# helper method to initialize an AARRR session
-def AARRR(env_or_model)
+def AARRR(env_or_model, attributes = nil)
if env_or_model.is_a?(Hash) and env_or_model["aarrr.session"]
env_or_model["aarrr.session"]
else
- session = AARRR::Session.new(env_or_model)
+ session = AARRR::Session.new(env_or_model, attributes)
# add to the rack env (if applicable)
env_or_model["aarrr.session"] = session if env_or_model.is_a?(Hash)
View
61 lib/aarrr/session.rb
@@ -49,7 +49,7 @@ def set_cookie(response)
end
# track event name
- def track!(event_name, options = {})
+ def track(event_name, options = {})
options = options.with_indifferent_access
# add event tracking
@@ -57,7 +57,7 @@ def track!(event_name, options = {})
"aarrr_user_id" => self.id,
"event_name" => event_name.to_s,
"event_type" => translate_event_type(options["event_type"]),
- "in_progress" => options["in_progress"] || false,
+ "complete" => options["complete"] || false,
"data" => options["data"],
"revenue" => options["revenue"],
"referral_code" => options["referral_code"],
@@ -77,35 +77,70 @@ def track!(event_name, options = {})
result
end
- # more helpers
+ def track!(event_name, options = {})
+ options[:complete] = true
+ track(event_name, options)
+ end
+
+ # helpers
- def acquisition!(event_name, options = {})
+ def acquisition(event_name, options = {})
options[:event_type] = :acquisition
- track!(event_name, options)
+ track(event_name, options)
+ end
+ alias :acq :acquisition
+
+ def acquisition!(event_name, options = {})
+ options[:complete] = true
+ acquisition(event_name, options)
end
alias :acq! :acquisition!
- def activation!(event_name, options = {})
+ def activation(event_name, options = {})
options[:event_type] = :activation
- track!(event_name, options)
+ track(event_name, options)
+ end
+ alias :act :activation
+
+ def activation!(event_name, options = {})
+ options[:complete] = true
+ activation(event_name, options)
end
alias :act! :activation!
- def retention!(event_name, options = {})
+ def retention(event_name, options = {})
options[:event_type] = :retention
- track!(event_name, options)
+ track(event_name, options)
+ end
+ alias :ret :retention
+
+ def retention!(event_name, options = {})
+ options[:complete] = true
+ retention(event_name, options)
end
alias :ret! :retention!
- def referral!(event_name, options = {})
+ def referral(event_name, options = {})
options[:event_type] = :referral
- track!(event_name, options)
+ track(event_name, options)
+ end
+ alias :ref :referral
+
+ def referral!(event_name, options = {})
+ options[:complete] = true
+ referral(event_name, options)
end
alias :ref! :referral!
- def revenue!(event_name, options = {})
+ def revenue(event_name, options = {})
options[:event_type] = :revenue
- track!(event_name, options)
+ track(event_name, options)
+ end
+ alias :rev :revenue
+
+ def revenue!(event_name, options = {})
+ options[:complete] = true
+ revenue(event_name, options)
end
alias :rev! :revenue!
Please sign in to comment.
Something went wrong with that request. Please try again.