Created
April 12, 2012 16:12
-
-
Save jparbros/2368725 to your computer and use it in GitHub Desktop.
omniture_common_params refactor #1
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
class ApplicationController < ActionController::Base | |
helper_method :omniture_common_params, :set_omniture_cookie | |
def omniture_common_params(omniture_data_objs) | |
omniture_data_arr = [omniture_data_objs].flatten.compact | |
# Set the omniture LOGIN | |
if params[:logged] || session['omn_fire_registration_success'] | |
omniture_data_arr.insert(0, Omniture.generate_params(:login_success, params)) | |
end | |
# Set the omniture REGISTRATION | |
if current_user && session['omn_fire_registration_success'] | |
omniture_data_arr.insert(0, Omniture.generate_params(:registration_success, params, { :account => current_user })) | |
session['omn_fire_registration_success'] += 1 | |
session['omn_fire_registration_success'] = nil if session['omn_fire_registration_success'] >= 2 | |
end | |
if omniture_data_arr.blank? | |
omniture_data_arr << Omniture.generate_params(:unknown_page, params, { | |
:controller => controller_name, :action => action_name }) | |
end | |
set_omniture_cookie | |
# Set the omniture PDP version | |
omniture_data_arr.each { |o| o.set_pdp_version(pdp_version) if o.respond_to?(:set_pdp_version) } | |
omniture_data_arr.size > 1 ? omniture_data_arr : omniture_data_arr.first | |
end | |
def set_omniture_cookie | |
visitor_id = cookies[:omniture] || request.session_options[:id] | |
cookies[:mc_id] = { | |
:value => visitor_id, | |
:expires => 10.years.from_now | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment