(function (w, d) {
  var dynamicPixel = function() {
    var pixelURL = "https://a.remarketstats.com/px/smart/?c=24d1add2443e239&amp;partner_id=04739b64b2ead18f3d80d2a4a70bd8f5&amp;partner_rid=e3f5283f%2d1f01%2d11f0%2d8855%2dff131b49c98c&amp;type=img&seg=";
    var urlPath = w.location.pathname.substr(1).replace(/\/+$/, '');
    if (urlPath === "") { urlPath = "home"; }
    console.log(urlPath);
    var segmentValue = urlPath;
    var script = d.createElement('script');
    if (pixelURL.indexOf("seg=") === -1) {
      pixelURL = pixelURL + "seg=";
    }
    script.src = pixelURL + escape(segmentValue);
    d.getElementsByTagName('script')[0].parentNode.appendChild(script);
  };

  var body = d.getElementsByTagName('body')[0];
  if (body) {
    dynamicPixel();
  } else {
    w.onload = function () {
      dynamicPixel();
    }
  }
})(window, document);
