Search code examples
phpgoogle-analyticsgoogle-analytics-api

Google Analytics API Filter for Index/Homepage


I'm trying to figure out how to construct a filter that will retrieve just the pageviews of my homepage using the Google Analytics API. I can get pageviews of other pages, for instance:

ga:hostname==mydomain.com;ga:pagePath=~/my-page/$

But I want pageviews of just mydomain.com/. I've tried the following and they don't work:

ga:hostname==mydomain.com;ga:pagePath=~//$ ga:hostname==mydomain.com;ga:pagePath=~///$ ga:hostname==mydomain.com;ga:pagePath=~/\//$ ga:hostname==mydomain.com;ga:pagePath=~/[\S]{1}/$

Any ideas? Thanks.


Solution

  • Try this:

    ga:pagePath==/
    

    If you want to use a regular expression, it would look like this:

    ga:pagePath=~^/$
    

    Here's a demo of this query using the Query Explorer: