-
Notifications
You must be signed in to change notification settings - Fork 10
Homepage dropdown engagement queries
Scroll to the bottom of the page for script instructions
With the addition of the responsive drop-down to the homepage search field (in the body of the page, not the header) there are Ahoy::Event
s created for each of the three types of links the user can click.
The events as they are saved to the db indicate which type of link was clicked which can be an Innovation page link, a Category link (which navs to the the /search
page with the category pre-selected as a filter, or a "Browse all" link which navs to the /search
page with no filters applied.
Querying the counts for these events is pretty straightforward, so simple ActiveRecord
queries are all that is needed.
Ahoy::Event.where(name: ""Dropdown Browse-all Link Clicked").count
Ahoy::Event.where(name: "Dropdown Practice Link Clicked").count
Ahoy::Event.where(name: "Category selected")
.where("properties ->> 'from_homepage' = 'true'").count
- These counts include events created from VA and non-VA user clicks, to get a count of just VA-user clicks (for any of the three event types) just check for a non-
nil
value for theuser_id
attribute:
Ahoy::Event.where(name: "Dropdown Practice Link Clicked")
.where.not(user_id: nil).count
- To get events created by non-VA user clicks just remove the
not
:
Ahoy::Event.where(name: "Dropdown Practice Link Clicked")
.where(user_id: nil).count
- Additionally, the
time
attribute can be utilized to filter for records created between a specific time span:
start_date = '2024-03-01'
end_date = '2024-03-31'
Ahoy::Event.where(name: "Category selected")
.where("properties ->> 'from_homepage' = 'true'")
.where.not(user_id: nil)
.where(time: start_date..end_date).count
Just keep in mind that the time attribute tracks down to the millisecond, so having a start and end date is necessary when filtering by the time
attribute. Also, when using a simple date format for the range as above, the time will always be 00:00, so the above query will include events created between March 01 at 00:00 and March 31 at 00:00
A script (rails task) file was added that queries the db for totals of all dropdown events created between given dates by day. To run in the console locally or in Jenkins run
bundle exec rails runner 'lib/tasks/dropdown_event_counter.rb' '2024-03-01' '2024-03-31'
This returns the following where "Date" is the given day, "Browse All" represents the number of clicks for the browse all categories and innovations links, "Innovations" is the number of innovation show page link clicks, and "Categories" is the number of individual category link clicks:
Date,Browse All,Innovations,Categories
03-15-2024,0,0,0
03-16-2024,0,0,0
03-17-2024,0,0,0
03-18-2024,0,15,0
03-19-2024,1,15,1
03-20-2024,0,0,13
03-21-2024,0,0,1
03-22-2024,0,0,0
03-23-2024,0,0,0
03-24-2024,0,0,0
03-25-2024,0,0,0
03-26-2024,0,0,0
03-27-2024,0,0,0
03-28-2024,0,0,0
03-29-2024,0,0,0
03-30-2024,0,0,0
03-31-2024,0,0,0
Note: The script returns the counts of dropdown link click events created by both VA and non-VA users, if we want to update the script to differentiate with an in-line arg we can, just lmk -Phil