Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Analytics without sending query string data

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.

like image 644
Joel Avatar asked Dec 29 '22 07:12

Joel


1 Answers

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's pathname (which excludes the query string) and uses it as the pagename value.

  _gaq.push(['_trackPageview', location.pathname ]);

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

  pageTracker._trackPageview(location.pathname);

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

like image 157
Yahel Avatar answered Dec 31 '22 01:12

Yahel