5

我在 Rails 5.1.5 中设置了 Ahoy,但它不会自动跟踪访问。

来自https://github.com/ankane/ahoy

Add this line to your application’s Gemfile:
gem 'ahoy_matey'

And run:
bundle install
rails generate ahoy:install
rails db:migrate

Restart your web server, open a page in your browser, and a visit will be created 

我将最后一行解释为:当有新访问时,一个条目将自动出现在 Ahoy::Visit.last 中。不幸的是,在页面浏览之后,此表中没有任何行。所以我在 application_controller.rb 中做了这个:

after_action :ahoy_track

private

def ahoy_track
  properties = request.path_parameters
  properties[:url] = request.url
  ahoy.track "Pageload", properties
end

现在我正在获取访问者数据。但是,当有人来自 Google 时,Ahoy::Visit.last.search_keyword 为 nil。

这两个问题有关系吗?是什么赋予了?这部署到 Heroku 的普通 PostgreSQL 设置上。

4

0 回答 0