Im setting up Ahoy gem
into my application, but there are some options that I don't understand where to add.
This is what I have done currently:
1) Added gem "ahoy_matey"
to my Gem File and ran Bundle install
& restarted my server
2) Added //= require jquery
& //= require ahoy
to my application.js
3) Ran rails generate ahoy:stores:active_record
and added new tables to my database by running rake db:migrate
I also have ahoy.rb
in my initializers folder.
At this point I can see that ahoy
is added in my application, but not sure how to do some stuff.
I want to add Ahoy.cookie_domain = :all
& Ahoy.visit_duration = 1.minute
, But I don't know where to add them
AND one other issue I have is that whatever page I go to is added to my Visits
table (PS: I haven't added any JS
or Ruby
code for tracking in any pages or controller) and as I see it ,ahoy gem
tracks all events/visits in my application. I only want to track events/visits on one particular action in my whole application, posts#show
action and rest don't need to be added at all.
How can I achieve this?
I want to add
Ahoy.cookie_domain = :all
&Ahoy.visit_duration = 1.minute
, But I don't know where to add them
You add them in the initializer that you created (./config/initializers/ahoy.rb
). This is precisely the purpose of files in that folder: Setting configuration values for the application to use.
whatever page I go to is added to my
Visits
table [...] I only want to track events/visits on one particular action in my whole application
The Gem's README says:
There are three ways to track events. [...] See Ahoy.js for a complete list of features.
So start there, and take a look at ahoy.js
if you need some more advanced configuration. The gem is very flexible - you just need to read the documentation and configure it as needed.