且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取 Google Analytics“访问者流量"来自 API 的数据

更新时间:2023-12-02 15:52:34

这真是个好主意.我对此有点晚了,但是您应该能够通过使用 Google Analytics Reporting API 下载所有数据,将其存储在本地数据库/文件/任何内容中,然后通过聚合手工统计并将其存储在本地.

This is a really great idea. I'm a little late to this, but you should be able to accomplish this by downloading all of the data using the Google Analytics Reporting API, store it in a local database/file/whatever, and then build your recommendation engine by aggregating the statistics by hand and storing them locally.

要从 Reporting API 获取数据,请尝试使用 query explorer 并提取数量使用类似于@carlsoja 的方法访问所有路径对之间的页面:

To get the data from the Reporting API, try playing with the query explorer and extracting the number of visits to pages between all pairs of paths using a method similar to @carlsoja:

dimensions=ga:previousPagePath,ga:pagePath&metrics=ga:visits

为了获得所有数据,您必须使用核心报告之一客户端库对结果进行分页(您可以在查询浏览器).

In order to get all of the data, you will have to use one of the Core Reporting Client Libraries to paginate through the results (which you can experiment with in the query explorer).

获得所有数据后,您可以非常轻松地计算一个人访问页面的马尔可夫链转换概率/A 在他们访问了页面 /Bp(/A |/B) 之后.如果某人在过去的某个时间点访问了页面 /B,那么估计他们访问页面 /A 的概率将非常简单.如果你真的想变得很花哨,你可以使用他们的完整历史 {H} 通过估计 p(/A | {H}) 来为页面推荐,但我将其作为练习留给读者;)

Once you have all of the data, you can pretty easily calculate the Markov Chain transition probabilities that a person visits page /A after they have visited page /B, or p(/A | /B). Then it would be pretty straightforward to estimate the probability that someone visits page /A if they visited page /B at some point in the past. If you wanted to get really fancy, you could use their complete history {H} to make recommendations for pages by estimating p(/A | {H}), but I'll leave that as an exercise for the reader ;)

希望这有帮助!