Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search & Replace Request URI Filter in Google Analytics

I have 2 landing pages:

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

Because the sessionID is unique, each of the landing page will be tracked as different pages. Therefore, I need a filter to remove the sessionID. These are what i want to track:

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

I created the Search and Replace Custom Filter on the Request URI:

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

But i get the /$1/index.php/$2/index/$3 being reported on the dashboard 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 the grouped patterns in the replace string?

My Solution: i managed to solve it using Advanced Filter. My solution:

Field A => Request URI: /(aa|bb)/index\.php/(aa|bb)/index/(.*)/(.*) 
Field B => - 
Output to => Request URI: /$A1/index.php/$A2/index/$A4
like image 964
zen.c Avatar asked Dec 06 '12 11:12

zen.c


People also ask

How I can search by Google?

Actually searching Google is pretty easy. Just type what you're interested in finding into the search box on the Google web site or into your toolbar! If you're using a toolbar, as you type, you may see words begin to appear below the toolbar's search box.

How do I find a figure?

Search with an image from a website On your computer, go to the Chrome browser. Go to the website with the image you want to use. Right-click the image. Click Search Image with Google Lens to display results in a sidebar.


1 Answers

I haven't used the Google Analytics regex engine, but it appears to me that \1 is referencing the entire match (which in other regex implementations is called \0), while \2 is the first group, \3 is the second group, and so on.

Your initial regex, however, looks incomplete--I think it should look as follows:

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 whether ? is supported in this regex implementation as the non-greedy modifier, but if it is, the above search string pattern might run a little faster if you change /.* to /.*?.)

like image 125
Kyle Strand Avatar answered Nov 15 '22 06:11

Kyle Strand