admin:online-platform-cms:3rd-party-scripts:zendesk

Zendesk

To use zendesk widget add this code to the custom script section:

// ZENDESK WIDGET START
window.zESettings = {
  webWidget: {
    offset: {
      horizontal: '1px',
      vertical: '1x',
      mobile: {
        horizontal: '-8px',
        vertical: '50px'
      }
    }
  }
};
var head = document.getElementsByTagName('head')[0];
script = document.createElement('script');
script.src = '<ZENDESK_SCRIPT_URL_WITH_KEY>';
script.id = 'ze-snippet';
head.appendChild(script)
// ZENDESK WIDGET END

To make it work for your case, insert zendesk script url with key, and change this line only:

script.src = '<ZENDESK_SCRIPT_URL_WITH_KEY>';

To change placement of widget, change these settings:

window.zESettings = {
  webWidget: {
    offset: {
      horizontal: '1px',
      vertical: '1x',
      mobile: {
        horizontal: '-8px',
        vertical: '50px'
      }
    }
  }
};

To hide zendesk chat widget in certain game(in this case `evolution`), add such snippet below:

// ZENDESK HIDE FOR EVOLUTION START
document.addEventListener("routeChange", routeChangeEvent => {
  if (routeChangeEvent.detail.moduleName === 'evolution') {
    waitzE(function() { zE('webWidget', 'hide')});
  } else {
    waitzE(function() { zE('webWidget', 'show')});
  }
});

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function waitzE(cb) {
  while(typeof zE !== "function") {
    await sleep(1000);
  }
  cb();
}
// ZENDESK HIDE FOR EVOLUTION END
  • admin/online-platform-cms/3rd-party-scripts/zendesk.txt
  • Last modified: 2022/03/31 14:13
  • by algirdas-matas