You'll need to check this.attr('href').indexOf('?') > -1 before just adding a key/value pair. If there's no '?' you'll need to add that too.
You're probably best off using the native href API in javascript to parse the URL then add the bits you require to the part of the URL you require modified.
http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
You should probably also consider doing this using an "on" event trigger (jQuery latest). Augmenting the DOM is slow when done to a lot of elements, and will delay page display if added in the onLoad hook.
$('body').on('click','a',function(e){
// Prevent it jumping straight out
e.preventDefault;
// Define vars
var href = this.href,
qstr = 'a=b&bar=foo';
// check for structure of url and add query string
this.href += ((href.indexOf('?') > -1) ? '&': '?') + qstr;
// jump
return true;
});