0

I want to count how many views my page has received. So, I try to use the Ahoy gem and add the following line into my action:

https://github.com/ankane/ahoy#ruby

Then it records when a visitor views that action, but it also records every time the action has been called, even when user reloads the page.

What I want is: if this is that the user's first visit we record it. But if they just reload page or they re-visit that page in a short amount of time, we will not save ahoy.track into our DB.

So, do anyone have a solution for this?

sreang rathanak
  • 502
  • 1
  • 4
  • 15

1 Answers1

1

try in your view :

<% ahoy.track_visit unless current_visit %>
ruby ninja
  • 36
  • 5