31

My site has user profiles that are accessible via URLs that look like this: www.domain.com/profile/123/.... I want to show users page view statistics of their profiles, but need to be able to do wildcards.

For example, this works:

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

The problem is that there are potentially other URI segments that follow /profile/123/. I want to do something like this (does not work):

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

Suggestions?

StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441

4 Answers4

37

Use the 'Contains a match for the regular expression' operator (~) from the Dimension Filters.

filters=ga:pagePath=~/profile/123/*
Yahel
  • 37,023
  • 22
  • 103
  • 153
  • 3
    @yahelc, The #~ is correct but * doesn't mean what you think in regular expressions. In fact filters=ga:pagePath=~/profile/123/ is sufficient in this case. – s6mike Oct 11 '12 at 05:55
  • I left the original double `==` in my query and was confused as to why it wasn't working...essentially: `filters=ga:pagePath==~/profile/123/*` >___ – Chris Kempen Aug 20 '14 at 15:49
4

This will work:

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

To do /*/view/* (as per @VinnyG’s comment), this should work:

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

I'm assuming you want to match one (and only one) directory before /view/.

s6mike
  • 497
  • 5
  • 16
1

Another filter from the Dimension Filters that would work for you is contains "=@"

ga:pagePath=@/profile/123

Roark
  • 1,082
  • 8
  • 9
0

worked for me.

    
    require('gapi.class.php');
    $ga = new gapi('mail@example.com','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();
    }
    ?>
Tag
  • 1
  • 1
  • GAPI Class (Google Analytics PHP Interface) http://code.google.com/p/gapi-google-analytics-php-interface/ – Tag Mar 16 '11 at 13:48
  • How to find Google Analytics Profile ID http://stackoverflow.com/questions/4119610/get-google-analytics-id-from-the-code-embed/4120625#4120625 – Tag Mar 16 '11 at 14:01