Is there a way to update in even in the ahoy_events table or track an event over time?

225 views Asked by At

We've been using Matomo for analytics tracking but have had tons of issues with their HTTP Tracking API and specifically the Media Analytics plugin. Their forums were no help and we received no help from the support email even though the Media Analytics plugin is expensive.

I decided to replace the Matomo functionality with Ahoy and so far it's been wonderful. My only question is how do I track a single event over time? Can I update an old event?

Here's my use case:

I want to track analytics of media watched. So when a user loads a video page we'll know that the page was loaded, when they started playing the media, whether they paused the video, seeked through the video, if/when they finished it etc.

I was thinking it may be easy if I could just update the initial event any time something changes but if that's not possible there has to be another way to combine this data easily. I'm just not seeing it.

1

There are 1 answers

2
eux On

My only question is how do I track a single event over time? Can I update an old event?

Yes, but you have to add codes manually.

Based on your use case, it may not be a good choose to use Ahoy or any other visits tracking tools, as they should track every visits naturally except for few exceptions. And the analytics result will be messed.

The better way is create a new model to do this, like User has_one UserStatus.

If you have to do it with Ahoy, you could work around like the pseudo code:

# ahoy.rb
Ahoy.exclude_method = lambda do |controller, _request|
  user = controller.current_user

  if (ahoy_visit = find_by_user_id)
    update ahoy_visit
    return true # Skip tricking
  end
end