Created
January 7, 2014 18:29
-
-
Save mcfunley/8304126 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'helpers/analytics' | |
analytics_cascade do | |
analytics_flow do | |
analytics_source 'visit_logs' | |
assembly 'visit_logs' do | |
unsequence 'visit', :output => ['event'] | |
query_event 'event', 'visit_id', 'event_type', 'query', 'epoch_ms' | |
keep_event_types 'cart_payment', 'search' | |
branch 'searches' do | |
keep_event_types 'search' | |
rename 'epoch_ms' => 'search_ms' | |
project 'visit_id', 'search_ms', 'query' | |
bottom 1, :by => 'search_ms', :within => ['visit_id', 'query'] | |
branch 'query_visits' do | |
group_by 'query' do | |
count 'visits' | |
end | |
end | |
end | |
branch 'purchases' do | |
keep_event_types 'cart_payment' | |
rename 'epoch_ms' => 'purchase_ms' | |
project 'visit_id', 'purchase_ms' | |
end | |
branch 'converted' do | |
join 'searches', 'purchases', :on => 'visit_id' | |
where 'search_ms:long < purchase_ms:long' | |
unique 'query', 'visit_id' | |
group_by 'query' do | |
count 'converted' | |
end | |
end | |
branch 'query_visit_conversion' do | |
inner_join 'query_visits', 'converted', :on => 'query' | |
end | |
end | |
compress_output :default, :block | |
analytics_sink 'query_visit_conversion' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment