if (document.location.search.match(/_ga=([^&]*)/)) {
// A small function to check if an object is empty
var isEmptyObject = function(obj) {
// Let's build an object with a key-value pairs from the current URL
var qsobject = document.location.search.replace(/(^\?)/, '').split("&").map(function(n) {
// Remove the _ga parameter
// Let's rebuild the querysting from the previous object with the _ga parameter removed
var rebuilt_querystring = Object.keys(qsobject).map(function(k) {
return encodeURIComponent(k);
return encodeURIComponent(k) + '=' + (encodeURIComponent(qsobject[k] || ""));
// We want to if the current querystring was null
if (isEmptyObject(qsobject)) {
new_url = location.pathname + location.hash;
new_url = location.pathname + '?' + rebuilt_querystring + location.hash;
// Use replaceState to update how the URL appears in the browser
window.history.replaceState({}, document.title, new_url);