How to get “Visitors Flow” data from Google Analytics GAPI API?

大憨熊 提交于 2020-01-15 03:08:04

问题


In Google Analytics there is a verry nice "visitor flow" page that clearly contains and keeps track of what path a visitor has taken on the site. Is it possible to get that data from the API? I know that you can use "custom variables" to give the users a unique ID and i do that already but what im after is to be able to use the data already collected without custom variables. I have got the following at the moment:

$ga->requestReportData(56786432, array('networkLocation', 'date', 'hour', 'nextPagePath', 'previousPagePath'), array('avgTimeOnSite', 'visits','pageviews'), array('-date', '-hour'), null, null, null, 1, 100);

This gives me visit "sessions" with date and hour and i think this is a start but how to continue from here? Is it possible?

EDIT I have now added nextPagePath and previousPagePath as new dimentions and pageviews as a metric. This gives somewhat of the path that the visitor went through the site. If the visitor went the path A->B->C->exit this gives me the result:

pageviews:1 previous:(entrence) next: :A
pageviews:1 previous:B next: :C
pageviews:1 previous:A next: :B

The above result is indeed correct but if the visitor went backwards and forwards on the site multiple times crossing from A->B and A->C multiple times its not possible for me to track when he went to B and when he went to C

pageviews:1 previous:(entrence) next: :A
pageviews:2 previous:A next: :C
pageviews:5 previous:A next: :B
pageviews:2 previous:C next: :A
pageviews4 previous:B next: :C

If its possible i need to get a result for each new page the visitor got to in the right order.

I saw this question already but it didnt get me any closer to my answer: Get Google Analytics "Visitors Flow" data from API


回答1:


I'm currently facing a similar problem using the Android SDK and I ran across both your question and this one. You can certainly get the flow data out of the Google Analytics Reporting API and run any kind of analysis on it you want. The challenge is that you will likely have to paginate through the results using one of the core reporting libraries to access all of the results.

Regarding your question about tracking the back/forward navigation movements, that might be good to ask as a separate question. If its possible, you will probably have to add some custom javascript on your page using the ga.js package somehow, but I'm not an expert on how to do that.

Note: I'm no lawyer, but I think it may be against the Google Analytics Terms of Service to try and track individual users in your application. If I am wrong, that would be delightful and I would like to start doing it myself!



来源:https://stackoverflow.com/questions/15185260/how-to-get-visitors-flow-data-from-google-analytics-gapi-api

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