facebook_app 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,17 +22,19 @@ module FacebookApp
22
22
  needs_login = ! (session[:at] && session[:oauth_expiry] && session[:oauth_expiry].to_i > Time.now.utc.to_i )
23
23
  if needs_login
24
24
  # tracking is only relevant for users who will log in
25
- track_conversion(:see_permissions_dialogue)
26
25
  session[:oauth_expiry] = nil
26
+ track_conversion(:see_permissions_dialogue)
27
27
  redirect_to oauth_code_link
28
28
  end
29
29
  end
30
30
 
31
31
  def begin_tracking
32
- Conversion.find_or_create(cookies[:conversion_id],params[:marketing_mode])
32
+ conversion = Conversion.find_or_create(cookies[:conversion_id],params[:marketing_mode])
33
+ cookies[:conversion_id] = conversion.id
33
34
  end
34
35
 
35
36
  def track_conversion(conversion_state)
37
+ Rails.logger.debug "Attempting to track #{conversion_state}"
36
38
  Conversion.track(cookies[:conversion_id], conversion_state)
37
39
  rescue
38
40
 
@@ -40,7 +40,7 @@ module FacebookApp
40
40
  end
41
41
 
42
42
  def self.track(conversion_id, conversion_event=nil, marketing_mode=nil)
43
- find_or_create(conversion_id, marketing_mode)
43
+ conversion = find_or_create(conversion_id, marketing_mode)
44
44
  conversion.send(conversion_event) unless conversion_event.nil?
45
45
  return conversion
46
46
  end
@@ -5,6 +5,12 @@ module FacebookApp
5
5
  (send(state, :viral).to_i.fdiv(send(state, :advertising).to_i)*100).to_s
6
6
  end
7
7
 
8
+ def percentage_of_total(state, marketing_mode)
9
+ (send(state, marketing_mode).to_i / splash_page_state_count(marketing_mode).to_i).to_s
10
+ rescue
11
+ "Cannot compute yet"
12
+ end
13
+
8
14
  def splash_page_state_count(marketing_mode)
9
15
  state_count(:splash_page, marketing_mode).to_s
10
16
  end
@@ -2,4 +2,8 @@ ul
2
2
  li = "Advertising: " + conversion_summary.send(state, :advertising)
3
3
  li = "Viral: " + conversion_summary.send(state, :viral)
4
4
  li = "Unknown or testing: " + conversion_summary.send(state, nil)
5
+ li = "Ration of all visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :all)
6
+ li = "Ratio of all advertised visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :advertising)
7
+ li = "Ratio of all viral visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :viral)
5
8
  li.virality= "Virality: " + number_to_percentage(conversion_summary.virality_coefficient(state))
9
+
@@ -1,3 +1,3 @@
1
1
  module FacebookApp
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: facebook_app
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.13
5
+ version: 0.0.14
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jack Kinsella