Get Google Analytics “Visitors Flow” data from API

别等时光非礼了梦想. 提交于 2019-11-28 07:38:34

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!

Is there any reason why you couldn't simply segment against people that viewed page A and use pagePath / pageTitle as a dimension and return the number of number of visits as the metric?

dimensions=ga:pagePath&metrics=ga:visits&segment=dynamic::ga:pagePath=~A

In theory this should list out all of the pagePaths that were viewed in the same visit as pagePath=~A and the number of visits where both were viewed, which is what you're looking for, yes?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!