Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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


Solution 2:

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.


Post a Comment for "Using Google Analytics Without Sending Query String Data"