使用 Google Analytics 获取数据以显示在我们的网页上? [英] Use Google Analytics for data to display on our webpage?

查看:31
本文介绍了使用 Google Analytics 获取数据以显示在我们的网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的某些页面上,我们会显示一些统计信息,例如该页面今天被查看的次数、过去一周被查看的次数等.此外,我们有一个整体统计页面,其中列出了这些页面,顺序是观看次数最多的.

On some of our pages, we display some statistics like number of times that page has been viewed today, number of times it's been viewed the past week, etc. Additionally, we have an overall statistics page where we list the pages, in order, that have been viewed the most.

今天,我们只是在这些浏览量和事件发生时将它们插入到我们的数据库中.我们还通过正常的页面跟踪及其 API 将它们发送到 Google Analytics.理想情况下,我们不查询我们的数据库以在我们的网页上显示这些统计信息,而是查询 Google Analytics 的 API.Google Analytics(分析)在确定真正独特的人是谁方面做得更好,并避免计算人为夸大其综合浏览量的人数(我们允许人们在我们的网站上创建页面).

Today, we just insert these pageviews and event counts into our database as they happen. We also send them to Google Analytics via normal page tracking and their API. Ideally, instead of querying our database for these stats to display on our webpages, we just query Google Analytics' API. Google Analytics does a FAR better job figuring out who the real uniques are and avoids counting people who artificially inflate their pageview counts (we allow people to create pages on our site).

那么问题是是否可以使用 Google Analytics 的 API 来更新我们网页上的统计信息?如果我缓存结果是否更可行?或者只是偶尔更新我们的统计数据?我非常喜欢 Google Analytics(分析)的网站指标,但也许有更好的解决方案来满足这种特殊需求?

So the question is if it's possible to use Google Analytics' API for updating the statistics on our webpages? If I cache the results is it more feasible? Or just occasionally update our stats? I absolutely love Google Analytics for our site metrics, but maybe there's a better solution for this particular need?

推荐答案

那么问题是是否可以使用 Google Analytics 的 API 来更新我们网页上的统计信息?

是的,是的.但是,身份验证过程和 xml 返回可能会减慢速度.您可以通过限制返回的行/列来加快速度.此外,您想要显示数据的方式的身份验证(如果我理解正确的话)将要求您使用客户端身份验证方法.您发送用户名和密码.安全是一个问题.

Yes, it is. But, the authentication process and xml return may slow things up. You can speed it up by limiting the rows/columns returned. Also, authentication for the way you want to display the data (if I understood you correctly) would require you to use the client authentication method. You send the username and password. Security is an issue.

我已经完全按照您的描述做了,但必须在页面上放置一个加载图形以获取统计信息.

I have done exactly what you described but had to put a loading graphic on the page for the stats.

如果我缓存结果是否更可行?或者只是偶尔更新我们的统计数据?

无论是缓存还是缓存似乎都可以工作,特别是因为 GA 数据无论如何都不是实时数据.您可以进行 api 调用并存储(或处理然后存储)返回的 xml 以供稍后显示.

Either one but caching seems like it would work especially since GA data is not real-time data anyway. You could make the api call and store (or process then store) the returned xml for display later.

我还没有这样做,但我想我可以试一试.甚至可以作为预定作业运行.

I haven't done this but I think I might give it a go. Could even run as a scheduled job.

我非常喜欢 Google Analytics(分析)的网站指标,但也许有更好的解决方案来满足这种特殊需求?

有一些第三方解决方案(谷歌搜索应该可以将它们根除),但应考虑资金和可行性.

There are some third-party solutions (googling should root them out) but money and feasibility should be considered.

这篇关于使用 Google Analytics 获取数据以显示在我们的网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆