views:

42

answers:

2

We're doing a simple implementation of Google Analytics on our ASP.NET with jQuery/AJAX web, and for most of it we just call _trackPageview and let Google do the rest.

We do a lot of data transfer in query strings, and recently, management became concerned that a lot of our data (such as product numbers) would be sent to Google. Without discussing whether that should be a concern:

Is it possible to use Google Analytics at all without sending the query string to Google's servers? I know how to filter it out from the actual reports, but I'm looking for a way to prevent it from being sent over the wire at all.

Thanks in advance.

+2  A: 

In stead of automatically tracking the pageview, you can use

pageTracker._trackPageview('/dir/example.html');

You'll have to dynamically strip out the parameters off of the url of each page. I'm not sure how to do that but it's definitely possible with JavaScript.

Litso
+2  A: 

Yes, as Litso said, you can send a whatever you want as the pathname for a GA page-view, but you'll want to automate the process with JavaScript.

The following code will take the current URL, and split it at the ? mark (where query strings begin), and then take everything from before the ? as the URL. This should work even if there's no ? in the URL (though I would test in IE to be sure; otherwise, just add an if check.)

  var baseurl = location.pathname.split('?')[0];
  _gaq.push(['_trackPageview', baseurl ]);

Or, conversely, if you're using the old _gat code,

  var baseurl = location.pathname.split('?')[0];
  pageTracker._trackPageview(baseurl);

So, if your URL is http://example.com/path/to/page.html?supersecretinfo, it will get tracked in GA as /path/to/page.html

yc
That's what I meant, glad someone could finish my story :)
Litso
Just tested in IE without any trouble. You can see it alerted out here: http://htmlto.com/redirect/alert.php?supersecretparameter
yc