Codestik
Codestik

Reputation: 77

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.

Upvotes: 3

Views: 1168

Answers (2)

Charles Skariah
Charles Skariah

Reputation: 670

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

Upvotes: 4

nautgrad
nautgrad

Reputation: 414

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.)

Upvotes: 1

Related Questions