4

In Google Analytics, field Site Content report, I always receive two data about one link, one with slash and one non Like this:

/post-one.html
/post-one.html/

I want to receive only data of (/post-one.html), then I create a Search and Replace filter:

Search string: \.html/$
Replace string: \.html$

But it doesn't work. How can I do it?

Charles
  • 51
  • 1
  • 5

3 Answers3

4

Search string: \/$

Replace string: empty string

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
2

You've got an extra * in there. Remove it.
You also need to remove the regex Kung fu from the replace string:

Search string: \.html/$
Replace string: .html
Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • I still don't understand why my replace string: \.html$ doesn't work? Why do I need to remove Regex in replace string? – Charles Aug 29 '14 at 15:11
  • 1
    The replace string is not regex, it's plain text, although it may contain "back references" to captured groups, eg `\1` for group 1 etc. – Bohemian Aug 30 '14 at 02:33
1

Based on some of the other comments and some experimentation, I realized that the Google help text actually implies that forward slashes in the Search field don't need to be escaped (so it's only quasi-regex):

A common use case for the Search and Replace filter is to turn multiple URLs into one. For example, to merge 'example.com/article/CA/planning+your+trip.html' and 'example.com/article/NY/exploring+the+country.html' so that your reports for the profiles for which you will apply this filter will show 'example.com/article/', please follow these steps:

Search String: example\.com/article/.*
Replace String: example\.com/article/

So I was able to create a Search/Replace Filter with the following:

Search String: [^^]/$
Replace String: [blank]

And it appears to be working.

woodardj
  • 313
  • 1
  • 2
  • 12
  • 1
    I understand this Filter. Thank you for your help. In my situation, it's the best to use Behemian's one (answer below). Because it only changes the link end with .html/ - That's what I want. Your filter changes everything end with slash / – Charles Nov 11 '14 at 02:02
  • Fair point. I should also update this because it causes problems with the site root. ie: ^/$ – woodardj Nov 12 '14 at 04:06