Permalink
Browse files

Merge pull request #147 from naleksi/proposal-preparation

Adding click tracking for sections and items within section, and for ideas
  • Loading branch information...
2 parents f9e9091 + fe94cb2 commit 1a348cd198d60f61c29c1b638d84dc63497a82c4 naleksi committed May 21, 2012
Showing with 15 additions and 5 deletions.
  1. +12 −2 app/controllers/pages_controller.rb
  2. +1 −1 app/views/pages/_drafts.html.haml
  3. +2 −2 app/views/pages/_ideas.html.haml
@@ -24,7 +24,11 @@ def home
session[:ab_section_count] = rand(2)+1 unless session[:ab_section_count]
KM.set({"section_count" => "#{session[:ab_section_count]}"})
["proposal_and_draft", "draft", "proposal"].each do |section|
- 3.times { |i| s = "ab_#{section}_#{i}_link"; KM.track(s, s) }
+ 3.times do |i|
+ section_index_link = "ab_section_#{section}_#{i}_link"
+ KM.track(section_index_link, section_index_link) # track both, which section and which item
+ KM.track(section_index_link, "ab_section_#{section}_link") # track only which section got the click
+ end
end
# B: two rows of examples:
@@ -35,7 +39,8 @@ def home
@proposals_and_drafts = (@proposals + @drafts).sort {|x,y| x.updated_at <=> y.updated_at}
@proposal_and_drafts_counts = @proposals_counts.merge @drafts_counts
- @ideas = Idea.published.where(state: 'idea').order("updated_at DESC").limit(4).includes(:votes).all
+ idea_count = 4
+ @ideas = Idea.published.where(state: 'idea').order("updated_at DESC").limit(idea_count).includes(:votes).all
@idea_counts = {}
@ideas.map do |idea|
for_count = idea.vote_counts[1] || 0
@@ -55,6 +60,11 @@ def home
end
end
+ idea_count.times do |i|
+ KM.track("ab_ideas_#{i}", "ab_ideas_#{i}") # track both, which section and which item
+ KM.track("ab_ideas_#{i}", "ab_ideas") # track just idea section got the click
+ end
+
@blog_articles = Article.published.where(article_type: 'blog').order("created_at DESC").limit(3).all
KM.identify(current_citizen)
@@ -4,7 +4,7 @@
%div{:class => klasses}
- if recent_draft = items[i]
.popular
- %h3.title=link_to shorten(recent_draft.title, 100, 20, "»"), idea_path(recent_draft), id: "ab_#{section}_#{i}_link"
+ %h3.title=link_to shorten(recent_draft.title, 100, 20, "»"), idea_path(recent_draft), id: "ab_section_#{section}_#{i}_link"
%div{id: "draft_bar#{i+item_counter}", class: "bar"}
- for_portion, for_, against_portion, against_ = items_counts[recent_draft.id]
- for_length = [35, (280-5-35)*for_portion].max
@@ -1,13 +1,13 @@
.grid_16.top_ideas.alpha
%h2 Ajankohtaiset ideat
- - @ideas.each do |idea|
+ - @ideas.each_with_index do |idea, i|
.idea
.grid_16.info
%span.type
Idea/
%span.date
= finnishDate(idea.updated_at)
- %h3=link_to shorten(idea.title + ": " + idea.summary, 200, 20, "»"), idea_path(idea)
+ %h3=link_to shorten(idea.title + ": " + idea.summary, 200, 20, "»"), idea_path(idea), id: "ab_ideas_#{i}"
.grid_16.statistics
- for_, against, comments, total = @idea_counts[idea.id]
%span.total #{total} ääntä:&nbsp;

0 comments on commit 1a348cd

Please sign in to comment.