[英]What should I use to get stats from other websites?
I don't know my question title is correct or not but let me explain you what I want to do.我不知道我的问题标题是否正确,但让我向您解释我想做什么。
So I want to generate a script from my dashboard website(eg dashboard.com) which user will put on his website's page( http://userwebsite.com/thankyou.php ) and when any user visit that page I want to store the number of visits of that page on my dashboard website( http://dashboard.com ).所以我想从我的仪表板网站(例如dashboard.com)生成一个脚本,用户将把它放在他的网站页面( http://userwebsite.com/thankyou.php )上,当任何用户访问该页面时,我想存储该页面在我的仪表板网站( http://dashboard.com )上的访问次数。
Currently I am using XMLHttpRequest .目前我正在使用XMLHttpRequest 。 So I generate a script which has the code of Ajax and that ajax hits a post request on my dashboard website(I am using some token for a particular script).
因此,我生成了一个包含 Ajax 代码的脚本,并且该 ajax 在我的仪表板网站上点击了一个发布请求(我正在为特定脚本使用一些令牌)。
I am not sure this is the right way or not to achieve my goal.I am sure you guys have seen these kind of scripts.我不确定这是不是实现我的目标的正确方法。我相信你们已经看过这些脚本。 There are so many websites (most popular Google Analytics).
有很多网站(最受欢迎的谷歌分析)。
Please help me what should I do for it, or it's fine to use ajax?请帮我该怎么办,还是用ajax就好了?
Thanks.谢谢。
JavaScript is a common choice for that type of thing, so you're on the right track with Ajax. JavaScript 是这类事情的常见选择,因此您在使用 Ajax 时走在正确的轨道上。 One of the advantages to the JavaScript approach is that it's simple for other users to add it on a site.
JavaScript 方法的优点之一是其他用户可以轻松地将其添加到站点上。
With your script, you can add options for naming the page, or recording certain actions, etc. You may have an issue if a user has disabled JavaScript, but that tends to be a small number of users these days.使用您的脚本,您可以添加用于命名页面或记录某些操作等的选项。如果用户禁用了 JavaScript,您可能会遇到问题,但现在这往往是少数用户。
I will say that I see GET requests used more often for that type of thing.我会说我看到 GET 请求更常用于这种类型的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.