Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to specify URL in filters pagePath core reporting api V3

I am building a web app that pulls data through the Core Reporting Api v3 from Google. I am using the client PHP library offered by Google. I am currently trying to specify a page and retrieve its pageviews for a time range. Every other seems to be working okay except for the fact that if a specfy a filter with ga:pagePath==http://link/uri then I get 0 all the time no matter the time range.

I think the problem is got to do with the setting of value for this pagePath. I want to have spearate data for the desktop version of the site and the smartphone version denoted by s. subdomain

Can anyone hint me on some tips and or tricks to use to get the required data?

Example URL: http://domain.com/user/profile/id/1 http://s.domain.com/user/profile/id/1

Thanks in advance!

like image 322
shawndreck Avatar asked Jul 08 '13 15:07

shawndreck


1 Answers

for the the default implementation of Google Analytics, ga:pagePath doesn't include the scheme or hostname so in your case you'd actually want to filter using ga:hostname and ga:pagePath together.

I suggest you use the Query Explorer to build your queries and get familiar with what will work. You can also use this tool to at least get a sense for what type of data the ga:pagePath and ga:hostname dimensions return before trying to filter on them. Finally, once you have the query you want, you can easily get the exact Core Reporting API query by clicking on the Query URI button.

Also check out the Combining Filters section of GA API docs.

So if you want filter on ga:pagepath for domain.com and s.domain.com separately you could do something like

filters=ga:pagePath==/user/profile/id/1;ga:hostname==domain.com filters=ga:pagePath==/user/profile/id/1;ga:hostname==s.domain.com

like image 131
Pete Avatar answered Nov 05 '22 16:11

Pete