Skip to content

Instantly share code, notes, and snippets.

@jparbros
Created April 12, 2012 16:17
Show Gist options
  • Save jparbros/2368768 to your computer and use it in GitHub Desktop.
Save jparbros/2368768 to your computer and use it in GitHub Desktop.
omniture_common_params refactor #2
class ApplicationController < ActionController::Base
include Omniture::Helper
end
module Omniture
module Helper
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment