I have a website with google Analytics, which provides information about from where visitors are coming.
My website has a registration form, and I would like to know from where the new register is coming (but without asking him).
For example, suppose a user were searching "cars"
in google.com, clicked my link (not adwords), and were registering in my website. How and from where can I read and save that this user was looking for "cars"
in google.com and clicked in my link? Are there any cookies generated by google?
You can store the referrer where the user came from in its session:
# in application_controller.rb
before_filter :store_referrer
private
def store_referrer
referer = request.referer.presence
if referer && !referer.start_with?('http://your.domain')
session[:referer] ||= referer
end
end
When the user signs up, you just pass that value to the user:
User.new(params[:user].merge(:referer => session[:referer]))
You User
should have a referer=
method that handles that url.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.