BrandenB171
BrandenB171

Reputation: 294

How to use the | (or) operator in google analytics filter?

I have a filter I want to apply to my google analytics chart embedded in my site. I want to filter ga:pagePathLevel2 to be one of a list of numbers;

Ideally I want it to be something like

 'filters' : 'ga:pagePathLevel2==/6|/7|/8',

but that doesnt work, My authorization button doesnt show up after that so apparently something doesn't work

Upvotes: 2

Views: 2587

Answers (1)

Philip Walton
Philip Walton

Reputation: 30461

You can use a the =~ syntax to set a regular expression filter if you want to match a URL part in several possible forms.

If your case, you could do something like:

'filters': 'ga:pagePathLevel2=~^/(6|7|8)'

On an unrelated note: if your auth button isn't showing up at all, it's almost certainly because you have a syntax error and has nothing to do with the filter syntax. If you open up the developer console, you should see the error being logged.

Upvotes: 2

Related Questions