ruby on rails - How to Track Devise User Registration as Conversion in Google Analytics -
i'm using devise rails 3.2 app , want able add track new registrations conversions in google analytics. i'd have new users directed same page being redirected now, if possible (i.e. may pass thru view redirects current page users redirected after create).
can please me figure out best way devise?
# users/registrations_controller.rb # post /resource def create build_resource if resource.save if resource.active_for_authentication? set_flash_message :notice, :signed_up if is_navigational_format? sign_up(resource_name, resource) respond_with resource, :location => after_sign_up_path_for(resource) else set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format? expire_session_data_after_sign_in! respond_with resource, :location => after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource respond_with resource end end def after_sign_up_path_for(resource) after_sign_in_path_for(resource) end
from top of head, i'd use flash.
on registrations_controller.rb
:
if resource.active_for_authentication? flash[:user_signup] = true # or find more appropriate set_flash_message :notice, :signed_up if is_navigational_format? sign_up(resource_name, resource) respond_with resource, :location => after_sign_up_path_for(resource) else set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format? expire_session_data_after_sign_in! respond_with resource, :location => after_inactive_sign_up_path_for(resource) end
then, on view redirect after signup, i'd render necessary code trigger google analytics event based on presence of flash[:user_signup]
.
Comments
Post a Comment