Google Analytics API: Filtruj według URI?
Moja strona ma profile użytkowników, które są dostępne za pośrednictwem adresów URL, które wyglądają tak: www.domain.com/profile/123/...
. Chcę pokazać użytkownikom statystyki wyświetleń strony ich profili, ale muszą być w stanie zrobić wildcards.
Na przykład działa to:
filters=ga:pagePath==/profile/123/
Problem polega na tym, że potencjalnie istnieją inne segmenty URI, które podążają za /profile/123/
. Chcę zrobić coś takiego (nie działa):
filters=ga:pagePath==/profile/123/*
Sugestie? 4 answers
Użyj operatora' Contains a match for the regular expression ' ( ~ ) z filtrów wymiaru .
filters=ga:pagePath=~/profile/123/*
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-04-25 18:59:37
To zadziała:
filters=ga:pagePath=~/profile/123/
Do zrobienia /*/view/*
(zgodnie z komentarzem @VinnyG), powinno zadziałać:
filters=ga:pagePath=~/[^/]+/view/
Zakładam, że chcesz dopasować jeden (i tylko jeden) katalog przed /view/
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-05 19:47:22
Zadziałało dla mnie.
require('gapi.class.php'); $ga = new gapi('[email protected]','google_analytics_password'); $filter = 'ga:pagePath==/home.php'; //first parameter is your Google Analytics profile id /* How to find Google Analytics Profile ID http://stackoverflow.com/questions/4119610/get-google-analytics-id-from-the-code-embed/4120625#4120625 */ $ga->requestReportData(0000000,array('pagePath'),array('pageViews','UniquePageviews'), '-pageViews', $filter); foreach($ga->getResults() as $result) { echo $result->getPageviews(); echo $result->getUniquePageviews(); echo $result->getPagePath(); } ?>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-03-16 14:01:18
Kolejnym filtrem z filtrów wymiarów, który będzie dla Ciebie działał, jest contains "=@"
ga:pagePath=@/profile/123
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-27 08:23:47