30

我的网站有用户配置文件,可通过如下所示的 URL 访问:www.domain.com/profile/123/.... 我想向用户显示其个人资料的页面查看统计信息,但需要能够使用通配符。

例如,这有效:

filters=ga:pagePath==/profile/123/

问题是后面可能还有其他 URI 段/profile/123/。我想做这样的事情(不起作用):

filters=ga:pagePath==/profile/123/*

建议?

4

4 回答 4

37

使用维度过滤器中的“包含正则表达式的匹配项”运算符 (~) 。

filters=ga:pagePath=~/profile/123/*
于 2010-11-22T17:26:42.953 回答
4

这将起作用:

 filters=ga:pagePath=~/profile/123/

要做/*/view/*(根据@VinnyG的评论),这应该有效:

filters=ga:pagePath=~/[^/]+/view/

我假设您想在/view/.

于 2012-10-11T05:58:40.043 回答
1

维度过滤器中另一个适合您的过滤器是contains "=@"

ga:pagePath=@/profile/123

于 2017-01-27T08:23:47.323 回答
0

为我工作。

    
    要求('gapi.class.php');
    $ga = new gapi('mail@example.com','google_analytics_password');
    $filter = 'ga:pagePath==/home.php';

    //第一个参数是您的 Google Analytics(分析)配置文件 ID

    /* 如何找到 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() 作为 $result)
    {
        回声 $result->getPageviews();
        回声 $result->getUniquePageviews();
        回声 $result->getPagePath();
    }
    ?>
于 2011-03-16T13:47:18.080 回答