2

I have many links on my site that have query strings that contain %26 (which is a URL-encoded ampersand). For example:

?action=keyword_results&f=company&q=Bausch+%26+Lomb+Canada+Inc.

Apparently, Google Analytics is prematurely decoding the query string and it treats the text after the %26 as a separate parameter.

I use the Exclude URL Query Parameters option to exclude most query parameters (including action, f, and q) from our results. But I am getting stats for hundreds of pages with query strings like ?+Lomb+Canada+Inc. and I can't exclude them because they are all different.

I've tried a variety of Google searches to see if this is a known bug. But all I found was people having trouble because they weren't encoding the ampersand.

Am I doing something wrong? Is this a bug? Is there anything I can do to clean up my reports?

toxalot
  • 11,260
  • 6
  • 35
  • 58

1 Answers1

1

You could try creating a "search and replace" filter on Request URI and use regex to replace '%26' with '&'. Unfortunately, I'm not too experienced with regex, so I can't really help you there; you might have to ask someone else to write one for you (or figure it out yourself, of course).

https://support.google.com/analytics/answer/1034834

edit: I think it could something as easy as: search string for: %26 replace it with: &

http://rubular.com/r/V7yrenW3tt

But just create a separate profile and test it, I guess.

ravb79
  • 722
  • 5
  • 8
  • I don't want to filter it because then I would lose that pageview. I want to exclude the parameter so that it gets lumped together with the rest that don't have a query string. Even if I wanted to filter the data, I don't think changing it to an ampersand would solve the problem. The problem is that Google is already changing it to an ampersand when they shouldn't be. – toxalot Nov 13 '13 at 12:56
  • @toxalot I reckon GA converts an *&* to *%26* because *&* should preferably be coded as *&* in the first place. Second, you're not filtering it from your data, you're changing the way the url is indexed, to what you initially intended it to be. But it's like I said, test it on a new profile and see whether it works for you or not. – ravb79 Nov 13 '13 at 13:01
  • I should've read it better. Two things: replacing the %26 with 'and' instead of '&' might solve it *OR* you could try double-encoding the ampersands in your site's links (http://stackoverflow.com/questions/13095416/does-request-querystring-automatically-url-decode-a-string) – ravb79 Nov 13 '13 at 16:25
  • I think you may have gotten this already, judging by your followup comment. But for completeness...GA is NOT converting *&* to *%26*. They are doing the REVERSE and they are doing it too early. Plus, *&* should NOT preferably be encoded as *&*. It depends on the purpose and use. When used in HTML as a parameter delimiter, the *&* should be HTML escaped as *&*. But when used in a parameter value, it should be url-encoded (percent-encoded) as *%26*. In regards to the filter, you are correct. I had *exclude* filters on the brain. – toxalot Nov 13 '13 at 18:29
  • I've created the filter on a test profile (view) to change the *&* to *and* and will let you know how it works. – toxalot Nov 13 '13 at 18:30
  • Yeah, I misread and didn't check my comment (on mobile phone). My apologies for any misunderstandings. – ravb79 Nov 13 '13 at 18:57
  • Unfortunately, that didn't work - I think because *%26* has already been converted before the filter happens. I'm going to contact Google. – toxalot Nov 15 '13 at 22:44
  • @toxalot Fair enough. Care to post their answer here? I'd like to know as well. – ravb79 Nov 16 '13 at 12:56
  • I will post back here when/if I get it working. I posted to the bug forum. So far 3 views and no answers. I'm not holding my breath. If anyone knows a better way to contact Google, let me know. http://productforums.google.com/d/topic/analytics/DudSkbAZ3BQ – toxalot Nov 17 '13 at 21:36