Fire AR pixel with MAID

by romanych

JavaScript

function fireAudienceReportPixel(trackpoint, maid) {
  var trackingUrl = "https://visitanalytics.userreport.com/hit.gif?t=" + encodeURIComponent(trackpoint);
  if (maid) {
  	trackingUrl += "&d=" + encodeURIComponent(maid);
  }
  
  /*
   * Please note:
   *  - FETCH API is not working in Internet Explorer
   *  - { withCredentials: true } is added to send cookie
   *  - Pixel invocation always show an error in developers console
   *  - Theefore, success function never called
   */
  
  fetch(trackingUrl, { withCredentials: true }).then(
    function() {
    	console.log("Pixel invoked successfully");
    },
    function() {
    	console.log("Pixel invokation failed");
    }
  );
}

fireAudienceReportPixel("XXXtailcode", "MY-MAID")