Search query filter and query replacement in Google Analytics

I have two landing pages:

/aa/index.php/aa/index/[sessionID]/alpha /bb/index.php/bb/index/[sessionID]/bravo 

Since the session ID is unique, each landing page will be tracked as different pages. So I need a filter to remove sessionID. This is what I want to track:

 /aa/index.php/aa/index/alpha /bb/index.php/bb/index/bravo 

I created a search and replaced the user filter in the request URI:

 Search String: /(aa|bb)/index\.php/(aa|bb)/index/(.*) Replace String: /$1/index.php/$2/index/$3 

But I get the message /$1/index.php/$2/index/$3 in the control panel the next day. So I tried /\1/index.php/\2/index/\3 but I got very strange results, //aa/index.php/aa/index/alpha/index.php/aa/index/aa .

Does anyone know how to reference grouped patterns in a replacement string?

My solution: I was able to solve this problem with an advanced filter. My decision:

 Field A => Request URI: /(aa|bb)/index\.php/(aa|bb)/index/(.*)/(.*) Field B => - Output to => Request URI: /$A1/index.php/$A2/index/$A4 
+6
source share
1 answer

I did not use the Google Analytics regex engine, but it seems to me that \1 refers to all the matches (which in other regular expression implementations is called \0 ), and \2 is the first group, \3 is the second group, etc.

However, your original regex looks incomplete - I think it looks like this:

 Search String: /(aa|bb)/index\.php/(aa|bb)/index(/.*)/(alpha|bravo) Replace String: /\2/index.php/\3/index/\5 

(Note that I'm not sure if ? Is supported as a non-greedy modifier in this regex implementation, but if so, the above search string template may work a little faster if you change /.* to /.*? )

+1
source

All Articles