Connect visitor data with JS SDK

Including Enhencer script

To start, copy the code below and paste it in the <head> element of every page.

<script src='https://cdn.enhencer.com/scripts/dataCollector.js?token={this.state.userId}'></script>
    

Listing page function

Add the function below to the loading/opening function of product listing pages.

window.enhencerCollector.listingPage({
    listingCategory: {listing category goes here}
})

Pass the category string to the function with slashes in-between. For example, 'shoes/men/outdoor'.

Product page function

For product detail pages, add the function below to the loading/opening function of your product detail pages.

window.enhencerCollector.productPage({
    productID: {product id goes here},
    productCategory: {product category goes here},
    price: {product price goes here}
})

Add to cart function

When a product is added to the cart, call the function below with the ID of the product that's added.

window.enhencerCollector.addedToBasket({
    productID: {product id goes here}
})

Purchase function

Call the function below when a purchase completed successfully. Pass the purchase products array as a parameter. Every product has to have id, price and quantity parameters at least.

window.enhencerCollector.purchased({
    products: {purchase products goes here}
})

Example for a 'purchaseProducts' variable would be:
[{id: 'lw-154', price: 89, quantity: 2}, {id: 'lw-301', price: 45, quantity: 1}]