Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track from which site user came from to my rails app?

I want to store url of user's referral website after sucessfull registration. In this case I can't use request.referer because user can visit few pages on my website before registration. But I need previous website url, for example http://google.com or http://facebook.com/somepage_id or whatever. I know that Google Analytics or Intercome can collect this data but I want something simple. Preferably without external APIs or libraries if this possible.

like image 736
Codestik Avatar asked Dec 14 '25 17:12

Codestik


2 Answers

There is ruby gem called 'ahoy', which can be used for this.

When someone visits your website, Ahoy creates a visit with lots of useful information.

  • traffic source - referrer, referring domain, landing page, search keyword
  • location - country, region, and city
  • technology - browser, OS, and device type
  • utm parameters - source, medium, term, content, campaign

Please find the link for more information, Ahoy

like image 165
Charles Skariah Avatar answered Dec 16 '25 19:12

Charles Skariah


When user reach your site create UserSession which will store request.referer also it has user_id. And during registration bind UserSession to created User by filling user_id. In this case you will get site from which user came + you can get some additional info from UserSession(user-agent, date, visited pages and etc.)

like image 41
nautgrad Avatar answered Dec 16 '25 18:12

nautgrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!