Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics API: filter by multiple URIs?

The issue is that i need to filter around 100 analytics URIs which is located in database(lets say most important pages of site), it can be queried one by one but i think it is not efficient. The goal is to filter all URIs at once. instead of

filters=ga:pagePath==/firstURI

i need some thing like

filters=ga:pagePath==/firstURI && /secondURI && /thirdURI && /...URI

I have played with http://ga-dev-tools.appspot.com/explorer/?csw=1 and searched documentation about it, but couldn't find anything! I hope you will be able to help me!

like image 825
user1418998 Avatar asked Mar 27 '14 12:03

user1418998


1 Answers

After very long and unpleasant play with Google Analytics Query Explorer 2 i came with solution like this one which does right job.

filters=ga:pagePath==/firstURI,ga:pagePath==/secondURI

IMPORTANT NO SPACES between filters

Reference Documentation

Combining Filters

Filters can be combined using OR and AND boolean logic. This allows you to effectively extend the 128 character limit of a filter expression. OR

The OR operator is defined using a comma (,). It takes precedence over the AND operator and may NOT be used to combine dimensions and metrics in the same expression.

Examples: (each must be URL encoded)

Country is either (United States OR Canada): ga:country==United%20States,ga:country==Canada

Firefox users on (Windows OR Macintosh) operating systems: ga:browser==Firefox;ga:operatingSystem==Windows,ga:operatingSystem==Macintosh AND

The AND operator is defined using a semi-colon (;). It is preceded by the OR operator and CAN be used to combine dimensions and metrics in the same expression.

Examples: (each must be URL encoded)

Country is United States AND the browser is Firefox: ga:country==United%20States;ga:browser==Firefox

Country is United States AND language does not start with 'en': ga:country==United%20States;ga:language!~^en.*

Operating system is (Windows OR Macintosh) AND browser is (Firefox OR Chrome): ga:operatingSystem==Windows,ga:operatingSystem==Macintosh;

ga:browser==Firefox,ga:browser==Chrome

Country is United States AND visits are greater than 5: ga:country==United%20States;ga:visits>5

like image 63
user1418998 Avatar answered Oct 05 '22 22:10

user1418998