Tracking Metrics with Ahoy and Blazer Discussion
great video, thank for sharing it !
Ahoy is a wonderfull gem when it comes to track !
I also use Ahoy::Event to track visit duration and sometimes to create heatmap of my page :p
more information if you want : http://www.tuto-ruby-gratui...
this is my free rails tutorial, it's in french but code is understandable :p
import ahoy from "ahoy.js";
Hey, Chris! It looks like a lot has changed with
ahoy in the past two years. Any way you could update this?
I don't think a whole lot has changed. They have instructions for using it with Webpacker now, but it seems mostly the same to me. Are you talking about anything specific?
No, it turns out I have a Rails 5 app that uses Webpacker, and what I implemented was apparently causing confusion in my app. I took the Webpacker stuff out and it works fine now. Thanks, anyway!
Hey Chris, does ahoy_matey only integrate with the devise User model? My colleague and I have been attempting to integrate it with another model called Product -- ignoring the User model altogether. Changing t.references :user to t.references :product.
Our app does not have user auth, and we just want to track visits and events in our Product model.
Does anybody have any examples of using Ahoy::Events in Blazer?? It seems the two should marry nicely, but I'm struggling to find any examples.
Blazer + Ahoy::Visits is easy, all the data points are proper fields... but with Ahoy::Events each useful piece of data is within Json and so Blazer won't parse it... (do I need to change field to JsonB??)
I want to track playback and video performance analytics (easy to do in Ahoy) and then display some of it in Blazer. But I can't work out how to delve into the properties of an Event/Visit?? Any clues?
Example: I can search by an event like "User Pressed Play" but I want to know [event].video_id or [event].current_playback_time in Blazer... then I can do average time played, number of playbacks per user, etc.
When I installed Ahoy, I just changed the migration to have the data type be JSONB and haven't experienced any issues.
From there, you could query in Blazer using regular SQL (perhaps like):
SELECT CAST((properties->>'video_id') AS INTEGER) FROM ahoy_events WHERE ahoy_events.name = 'User Pressed Play' AND ahoy_events.time >= '2020-12-01 00:00:00';
This assumes that you have a field called 'video_id' in your properties hash. Basically we're fetching the string value from JSONB and then casting it to an intger. You could also join on that, potentially, like:
SELECT ahoy_events.*, videos.* FROM ahoy_events JOIN videos ON videos.id = CAST((properties->>'video_id') AS INTEGER) WHERE ahoy_events.name = 'User Pressed Play' AND ahoy_events.time >= '2020-12-01 00:00:00';
I hope this gives you some ideas. If you have something else in mind, let me know, maybe I can assist further.