Shoora
10/18/2018 - 2:26 PM

ga-classic-track-0-serch-results-c.js

Track 0 Serch Results with if statment

/* Track 0 Serch Results with if statment */

var content = document.getElementById('middlewrapper');
if (content.innerHTML.search('Inga produkter hittades!')) {

  var sn = "q"; 
  var sr = new RegExp(sn+"=[^\&]+"),
  p = document.location.pathname,
  s = document.location.search,
  sm = s.match(sr).toString(),
  srs = sm.split("="),
  
  sre = sm.replace(sr,srs[0]+"=no-results: "+srs[1]+"&cat=no-results"),
  sf = s.replace(sr,sre);
  
  _gaq.push(['_trackPageview', p + sf]);
  
}
/* Track 0 Serch Results */

var sn = "q"; 
var sr = new RegExp(sn+"=[^\&]+"),
p = document.location.pathname,
s = document.location.search,
sm = s.match(sr).toString(),
srs = sm.split("="),

sre = sm.replace(sr,srs[0]+"=no-results: "+srs[1]+"&cat=no-results"),
sf = s.replace(sr,sre);

_gaq.push(['_trackPageview', p + sf]);