如何使用rails从用户请求URL中获取以下信息。
连接类型(移动/ wifi)-设备品牌(applle,htc)-设备型号(ipad,iphone)-语言(英语),操作系统(ios,windows,blackberry),浏览器(chrome,firefox)
示例:当用户输入URL链接“ http://example.com/samples ”时,我需要跟踪来自Rails服务器的请求的详细信息。
可以使用rails方法吗?请帮我解决这个问题。谢谢
通过http://detectmobilebrowsers.com/检测移动浏览器
检测操作系统
def get_operating_system
if request.env['HTTP_USER_AGENT'].downcase.match(/mac/i)
"Mac"
elsif request.env['HTTP_USER_AGENT'].downcase.match(/windows/i)
"Windows"
elsif request.env['HTTP_USER_AGENT'].downcase.match(/linux/i)
"Linux"
elsif request.env['HTTP_USER_AGENT'].downcase.match(/unix/i)
"Unix"
else
"Unknown"
end
end
当有人访问您的网站时,Ahoy会创建包含许多有用信息的访问。
traffic source - referrer, referring domain, landing page, search keyword location - country, region, and city technology - browser, OS, and device type utm parameters - source, medium, term, content, campaign
参考链接:http : //ankane.github.io/ahoy/
Mobvious检测是否通过电话,平板电脑或个人计算机访问您的应用程序/网站。
参考链接:https : //github.com/jistr/mobvious
使用Ruby进行一些浏览器检测。包括ActionController集成。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句