AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
2K members online now
2K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

Filter to strip out entire query string

Google Employee
# 1
Google Employee

This popular discussion was copied from the former Help Forum, answered by

Whims/vgrinko14 (TC/member)

 

Question:

Hello everyone,

 

in one of my GA views I need to strip out all query string parameters using filter.

I was advised to create search and replace filter with the following configuration:

Dimension: Request URI

Search String: ^([^\?]+)\?.*

Replace String: \1

 

I am looking at "Replace String" I don't get what it means "\1". Can anyone help me understand how this filter works?

Answer:

Whims, thank you for your reply!

Actually, it seems to be working as expected in my test view, but I didn't understand why initially.

Now I discovered, that "\1" is actually "back reference" for everything what matches regular expression "[^\?]+" - in the brackets.

 

So my filter works as that it extracts content from the RequestURl before "?" sign, and replaces entire Request URl with this substring.



After some investigation I found these discussions, which other people may also find useful:

1) https://productforums.google.com/forum/?hl=en#!category-topic/analytics/discuss-google-analytics-fea...

2) Info about Regexp Back-references:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-bac...

 

given by Whims/vgrinko14 (TC/member)

1 Expert replyverified_user

Re: Filter to strip out entire query string

Google Employee
# 2
Google Employee
Hope you find this thread useful; let us know by starring it. Thanks!