本文介绍了获取Google Analytics“访问者流量”来自API的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Google Analytics收集信息,为我的网站构建推荐引擎。该网站由许多页面组成,因此我正在跟踪用户点击的次数,例如,从页面A到页面B.目前,我可以测量 A - >使用 previousPagePath ='/ A' nextPagePath ='/ B' c>,但我真正想回答的问题是,在包括查看页面A的网站的所有访问中,在同一次访问中查看了多少次页面B,C ......



例如,如果流量 A - >主页 - > B ,那么我的当前方法就不会捕捉到这一点,但会被更广泛的度量所捕获。看起来Google Analytics(分析)网络界面上的访问者流报告有我正在查找的数据,但我无法弄清楚如何通过API以编程方式访问它。



获取这些数据的最佳方法是什么?

解决方案

这真是个好主意。我对此有点迟了,但您应该可以通过使用Google Analytics报告API下载所有数据并将其存储在本地数据库/文件/任何内容中来实现此目的,然后通过将您的推荐引擎手动统计并将其存储在本地。

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

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

为了得到所有数据,您必须使用之一对结果进行分页(您可以在中试验)。



获得所有数据后,您可以非常轻松地计算访问过页面 / B p(/ A | / B)。那么,如果他们在某处访问页面 / B 时,估计某人访问页面 / A 的概率是非常简单的指向过去。如果你想变得很花哨,你可以使用完整的历史 {H} 来估计 p(/ A | {H }),但我会把它作为读者的练习;)

希望这有助于您!


I'm trying to gather information from Google Analytics to build a recommendation engine for my site. The site consists of many pages, so I'm tracking the number of times a user clicks, for example, from page A to page B. Currently I can measure the A -> B transitions on Google Analytics with previousPagePath = '/A' and nextPagePath = '/B', but the question I really want to answer is, "Of all the visits to the site that included viewing page A, how many times were pages B, C, ... viewed in the same visit?"

For example, if the flow was A -> homepage -> B, then that would not be captured by my current methodology, but would be captured by the broader measure. It looks like the "Visitors Flow" report on the Google Analytics web interface has the data I'm looking for, but I can't figure out how to access it programmatically via the API.

What is the best way to get this data?

解决方案

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.

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).

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 ;)

Hope this helps!

这篇关于获取Google Analytics“访问者流量”来自API的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:55