I have Ahoy integrated with a Rails app, working fine. I have introduced a new concept to the Visit model, a 'visitor_email', that is set if the user enters the site with a particular param in the URL (set in /initializers/ahoy.rb). That all works fine.
What I would like to do in addition to this is to create a cookie with this visitor_email. That cookie would then be used to uniquely identify the user if they came back to the site (without the unique param in the URL and also after the ahoy visit had expired) - it would be used to assign that same 'visitor_email' to the new Visit.
I cannot create / use these cookies in /initializers/ahoy.rb, of course. Creating the cookie in a before_action in application_controller is... fine, I guess. But I cannot use the cookie value to set the visitor_email in a new visit with the same method. What is the preferred method of handling this?