Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

This guide is designed to help you integrate your X instance autonomously once it has been fully instrumented.

...

Code Block
languagexml
themeEclipse
<script async defer src="https://assets.empathybroker.com/empathyx/{INSTANCE}/app.js"></script>

The async and The defer attributes attribute help to keep it blazing fast by loading the resource asynchronously and without blocking the page load. Once the script is ready, X will automatically call the global initEmpathyX function (see the Initializing X section).

...

Code Block
languagejs
themeEclipse
titleAdd2Cart example
// HTML approach
<button class="add2Cart" onclick="EmpathyX.addToCartOnProductPageClicked()"/>

// JS addEventListener approach
<script>
	document.querySelector('{ADD_TO_CART_SELECTOR}').addEventListener('click', function() {
		EmpathyX.addToCartOnProductPageClicked();
	});
</script>


Info
iconfalse

(warning) Notice that add2cart event has to be fired as many times as product is added to cart and related with the quantity of products added to cart. (i.e if quantity == 2, the event has to be fired twice)

Anchor
integrating-checkout
integrating-checkout
Integrating checkout

Code Block
languagejs
themeEclipse
titleCheckout example
<script>
document.querySelector('<checkout>').addEventListener('click', function() {
	// Get the product ids from your basket/checkout in any manner (your custom implementation)
	var productsIds = getCheckoutProductsIds();
	EmpathyX.checkout(productsIds);
});
</script>


Info
iconfalse

(warning) Notice that product's quantity has to be considered when creating the productsIds array  (i.e if quantity == 2, the productId has to be added twice to the productsIds array)

Anchor
polyfills-and-browser-support
polyfills-and-browser-support
Polyfills and browser support

...

  • The main scrollable element is html instead of body: X is mounted in the body element and uses a special class called ebx-empathy-x--opened to disable its scroll while opened. This will not work if the scrollable element is html.
  • The default scroll behavior is overriden with JavaScript and interfering with X.