在Rails中跟踪用户的点击次数和页面访问次数

时间:2021-12-20 14:04:26

I would like to monitor users' page visits and clicks in my Rails app to make recommendations. My questions are:

我想在我的Rails应用中监控用户的网页访问次数和点击次数,以提出建议。我的问题是:

  • Is there a Rails gem for this, or Google Analytics is the standard? If latter is true, then how should I link a page visit to a particular user profile?
  • 是否有Rails宝石,或谷歌分析是标准?如果后者属实,那么我应该如何将页面访问链接到特定的用户配置文件?

  • It is typical in Rails to have a section in application.html.erb, which is shared for all pages. If I add Google Analytics pageview tracking code to in application.html.erb, will it be able to track all individual pages?
  • Rails中典型的是在application.html.erb中有一个部分,它对所有页面都是共享的。如果我在application.html.erb中添加Google Analytics综合浏览量跟踪代码,是否可以跟踪所有单独的网页?

3 个解决方案

#1


8  

There are other ways, but the vast majority probably use Google Analytics. Several gems exist that help you integrate with GA to get at the data. See here: https://www.ruby-toolbox.com/categories/Web_Analytics.

还有其他方法,但绝大多数可能使用Google Analytics。有几种宝石可以帮助您与GA集成以获取数据。请参阅:https://www.ruby-toolbox.com/categories/Web_Analytics。

Based on your first question, it seems you may want more insight than GA can provide. I've used ClickTale (http://www.clicktale.com) and Woopra (http://www.woopra.com) before, to good effect. This article lists several other alternatives, too - notice the high marks for Clicky: http://imimpact.com/web-stats-alternatives-to-google-analytics/.

根据您的第一个问题,您似乎可能需要比GA更多的洞察力。我之前使用过ClickTale(http://www.clicktale.com)和Woopra(http://www.woopra.com),效果很好。本文还列出了其他几种替代方案 - 请注意Clicky的高分:http://imimpact.com/web-stats-alternatives-to-google-analytics/。

Google Analytics (and almost all of these others) will take care of your second question automatically whenever the user loads a new page, since it keyed by URL. That means that, although you put the GA script code in a single place, each unique page is tracked individually.

谷歌分析(以及几乎所有其他人)将在用户加载新页面时自动处理您的第二个问题,因为它由URL键入。这意味着,尽管您将GA脚本代码放在一个位置,但每个唯一页面都会被单独跟踪。

If you have AJAX requests that change that page without changing the URL, you'll need to dig in to the GA script API. Essentially you'll need to push a new url (possibly with a # in it) whenever you want to track an AJAX-driven link/button click. See here: http://davidwalsh.name/ajax-analytics

如果您有AJAX请求更改该页面而不更改URL,则需要深入了解GA脚本API。基本上,只要您想跟踪AJAX驱动的链接/按钮点击,您就需要推送一个新的URL(可能带有#)。见这里:http://davidwalsh.name/ajax-analytics

#2


9  

I am biased, but I would recommend checking out impressionist, if you need to integrate the page views into the app in real-time. With analytics you will always have some lag time and you are also relying on an external dependency. Impressionist is good if you need this kind of control, but if you are just looking for simple metrics and don't need to pull them into the app, then analytics is probably the way to go.

我有偏见,但如果您需要将页面视图实时集成到应用程序中,我建议您查看印象派。使用分析,您将始终有一些延迟时间,并且您也依赖于外部依赖。如果您需要这种控制,印象派很好,但如果您只是寻找简单的指标而不需要将它们拉入应用程序,那么分析可能就是您的选择。

#3


4  

Check out Ahoy, at https://github.com/ankane/ahoy. With just a few lines of code in your app, you can track page views and tie them to user accounts.

查看Ahoy,访问https://github.com/ankane/ahoy。只需在应用中使用几行代码,您就可以跟踪网页浏览量并将其与用户帐户相关联。

You can further customize Ahoy to track custom events, both the client (with JavaScript) and server.

您可以进一步自定义Ahoy以跟踪自定义事件,包括客户端(使用JavaScript)和服务器。

Ahoy does not depend on any third-party services.

Ahoy不依赖任何第三方服务。

#1


8  

There are other ways, but the vast majority probably use Google Analytics. Several gems exist that help you integrate with GA to get at the data. See here: https://www.ruby-toolbox.com/categories/Web_Analytics.

还有其他方法,但绝大多数可能使用Google Analytics。有几种宝石可以帮助您与GA集成以获取数据。请参阅:https://www.ruby-toolbox.com/categories/Web_Analytics。

Based on your first question, it seems you may want more insight than GA can provide. I've used ClickTale (http://www.clicktale.com) and Woopra (http://www.woopra.com) before, to good effect. This article lists several other alternatives, too - notice the high marks for Clicky: http://imimpact.com/web-stats-alternatives-to-google-analytics/.

根据您的第一个问题,您似乎可能需要比GA更多的洞察力。我之前使用过ClickTale(http://www.clicktale.com)和Woopra(http://www.woopra.com),效果很好。本文还列出了其他几种替代方案 - 请注意Clicky的高分:http://imimpact.com/web-stats-alternatives-to-google-analytics/。

Google Analytics (and almost all of these others) will take care of your second question automatically whenever the user loads a new page, since it keyed by URL. That means that, although you put the GA script code in a single place, each unique page is tracked individually.

谷歌分析(以及几乎所有其他人)将在用户加载新页面时自动处理您的第二个问题,因为它由URL键入。这意味着,尽管您将GA脚本代码放在一个位置,但每个唯一页面都会被单独跟踪。

If you have AJAX requests that change that page without changing the URL, you'll need to dig in to the GA script API. Essentially you'll need to push a new url (possibly with a # in it) whenever you want to track an AJAX-driven link/button click. See here: http://davidwalsh.name/ajax-analytics

如果您有AJAX请求更改该页面而不更改URL,则需要深入了解GA脚本API。基本上,只要您想跟踪AJAX驱动的链接/按钮点击,您就需要推送一个新的URL(可能带有#)。见这里:http://davidwalsh.name/ajax-analytics

#2


9  

I am biased, but I would recommend checking out impressionist, if you need to integrate the page views into the app in real-time. With analytics you will always have some lag time and you are also relying on an external dependency. Impressionist is good if you need this kind of control, but if you are just looking for simple metrics and don't need to pull them into the app, then analytics is probably the way to go.

我有偏见,但如果您需要将页面视图实时集成到应用程序中,我建议您查看印象派。使用分析,您将始终有一些延迟时间,并且您也依赖于外部依赖。如果您需要这种控制,印象派很好,但如果您只是寻找简单的指标而不需要将它们拉入应用程序,那么分析可能就是您的选择。

#3


4  

Check out Ahoy, at https://github.com/ankane/ahoy. With just a few lines of code in your app, you can track page views and tie them to user accounts.

查看Ahoy,访问https://github.com/ankane/ahoy。只需在应用中使用几行代码,您就可以跟踪网页浏览量并将其与用户帐户相关联。

You can further customize Ahoy to track custom events, both the client (with JavaScript) and server.

您可以进一步自定义Ahoy以跟踪自定义事件,包括客户端(使用JavaScript)和服务器。

Ahoy does not depend on any third-party services.

Ahoy不依赖任何第三方服务。