2

My sites is being bombarded with new and old URL parameters. At first I tried to add those to the list of excluded URL parameters. With that list now exceeding 200, I wanted to try and use a GA advanced filtern.

However, the only filter I found would exclude ALL parameters:

Create an advanced filter
Filter name: remove all query parameters from URI Filter type: advanced Filter field A: Request URI Filter
Field A pattern: (.)\?(.)
Field B: leave it blank
Output field: Request URI
Output pattern: $A1
Override output: YES Case Sensitive: NO

Source

The only parameters I'd like to not be filteted are query and page.
Does anyone know how to alter the regex accordingly?

1
  • They're standard Perl-like regex patterns, so try: ^query$ in Field A and ^page$ in Field B.
    – dan
    Commented Feb 11, 2015 at 1:03

1 Answer 1

2

Ok, so I was able to to solve my problem.

First I setup a new advanced filter:

Filter name:      remove all query parameters from URI except query and page   
Filter type:      advanced   
Filter field A:   Request URI Filter    
Field A pattern:  (.*?)\?   
Filter field B:   Request URI Filter   
Field B:          [\?|&](page=\d+|query=[^&]*) 
Output field:     Request URI Output pattern: $A1?$B1 
Field A required: YES   
Field B required: NO  
Override output:  YES   
Case Sensitive:   NO

In addition I created a second advanced filter which filters unnecessary ? at the end of the URL, using the regex (.*)\?$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.