JavaScript API
Control the Messenger from your own code — identify users, send events and carts, open the chat, start tours.
After the snippet loads, call Shopxare(command, …) from your page. Calls made before the script has loaded are queued and run in order.
boot
Starts the Messenger. app_id is required.
Shopxare('boot', {
app_id: 'YOUR_APP_ID',
user_id: '42', // your own ID for a logged-in user
user_hash: 'HMAC…', // see Identity verification
email: '[email protected]',
name: 'Ada Lovelace',
phone: '+48 600 000 000',
attributes: { plan: 'pro', shop_orders: 3, shop_cart_items: 2, shop_cart_total: '59.90', shop_currency: 'EUR' },
company: { company_id: '7', name: 'Analytical Ltd' },
hide_default_launcher: false,
});
attributesbecome custom attributes on the contact.- Shop data shows as a Shop card next to the conversation:
shop_orders,shop_total_spent,shop_currency,shop_cart_items,shop_cart_totalandshop_viewing_product. The WordPress plugin and the Shopify snippet send these for you. - Set
hide_default_launcher: trueto hide the round button and open the Messenger from your own button.
update
Send new user data, for example after login.
Shopxare('update', { email: '[email protected]', attributes: { plan: 'business' } });
show, hide and showNewMessage
Shopxare('show'); // open the Messenger
Shopxare('hide'); // close it
Shopxare('showNewMessage'); // open a new conversation
trackEvent
Record something the customer did. Events appear on the contact, work in segments and can start flows.
Shopxare('trackEvent', 'added_to_cart', { sku: 'A-100', price: 49 });
cart and purchase
Tell Shopxare what is in the cart, for cart reminders on platforms that don't send carts themselves. Send the whole cart each time it changes, and purchase after checkout.
Shopxare('cart', {
items: [{ title: 'Linen shirt', quantity: 1, price: 39.9, image: 'https://…/shirt.jpg', url: 'https://…/linen-shirt' }],
total: 39.9,
currency: 'EUR',
url: 'https://shop.example.com/cart',
});
Shopxare('purchase');
startTour
Start a product tour from your page — for example from a "Show me around" link. It works even if the visitor finished the tour before.
Shopxare('startTour', 'TOUR_ID');
Listen for changes
Shopxare('onUnreadCountChange', (count) => { /* update your badge */ });
Shopxare('onShow', () => {});
Shopxare('onHide', () => {});
Shopxare('onOpenUrl', (url) => { /* open links yourself, e.g. in your app */ });
shutdown
Call this on logout. It ends the session, so the next person on the same browser does not see the conversations.
Shopxare('shutdown');
Still stuck? Contact