SDK Reference
Audience: Developers who need to manually fire events, read behavioral state, or customise SDK behaviour.
The Reevix SDK is a lightweight (< 12 kB gzipped), async JavaScript library that loads via a single tag. All interactions go through the global rvx() function.
Initialization
The SDK initialises automatically when the script loads. You do not need to call an init function. The snippet in your Installation page includes your storeId:
<script async src="https://cdn.reevix.ai/sdk/v2/rvx.js"
data-store-id="sto_abc123">
</script>
If you need to wait for the SDK to be ready before calling rvx():
window.rvxReady = window.rvxReady || []
window.rvxReady.push(function() {
// SDK is ready
rvx('track', 'custom_event', { value: 99 })
})
Tracking Events
Page View
Reevix automatically tracks page views — including SPA navigation via pushState/replaceState. You only need to call this manually if your SPA uses a custom router that doesn't trigger these standard events:
rvx('page', {
url: window.location.href,
title: document.title,
category: 'product', // optional
productId: 'prod_xyz', // optional
})
Add to Cart
Fires automatically on most Shopify and WooCommerce setups. Manual call:
rvx('addToCart', {
productId: 'prod_xyz',
variantId: 'var_456', // optional
price: 49.99,
currency: 'USD',
quantity: 1,
})
Checkout Started
rvx('checkoutStart', {
cartValue: 149.99,
currency: 'USD',
itemCount: 3,
})
Purchase / Conversion
This is the most important event. Always fire it on your order confirmation page:
rvx('convert', {
orderId: 'ord_789',
total: 149.99,
currency: 'USD',
itemCount: 3,
})
Without this event, Reevix cannot attribute revenue or learn from successful conversions.
Custom Events
Fire any named event with an arbitrary payload:
rvx('track', 'wishlist_add', {
productId: 'prod_xyz',
source: 'product_page',
})
Custom events appear in analytics under Custom Events and can be used as autopilot triggers.
Reading Behavioral State
Get the current session's behavioral state:
const state = rvx('getState')
// Returns: 'exploring' | 'comparing' | 'evaluating' | 'ready' | 'buying' | null
Example use case — conditionally show a custom banner for high-intent shoppers:
if (rvx('getState') === 'ready') {
document.getElementById('urgency-banner').style.display = 'block'
}
Cart Integration
Manual Cart Sync
If Reevix cannot detect your cart automatically, provide it:
rvx('cart', {
items: [
{ productId: 'prod_xyz', variantId: 'var_1', price: 49.99, quantity: 2 },
{ productId: 'prod_abc', price: 29.99, quantity: 1 },
],
subtotal: 129.97,
currency: 'USD',
})
Call this on every cart mutation (add, remove, quantity change).
Cart-Aware Nudges
Use the SDK to request context-aware cart nudges:
const nudge = rvx('getCartNudge')
// Returns: { type: 'free_shipping', message: 'Add $20.03 for free shipping!' }
// or: { type: 'bnpl', message: 'Pay in 4 interest-free payments of $32.49' }
// or: null (no nudge available)
Display the nudge.message anywhere in your cart UI.
Product Recommendations
Fetch recommendations programmatically and render them yourself:
const recs = await rvx('recommend', {
type: 'similar', // 'similar' | 'complementary' | 'trending' | 'personalized' | 'recently_viewed' | 'bought_together'
productId: 'prod_xyz', // required for similar/complementary/bought_together
limit: 6,
})
// recs is an array of product objects:
// [{ id, title, price, originalPrice, imageUrl, url, rating, reviewCount, inStock }]
Recommendations are cached for 5 minutes client-side.
Identify (User Identity)
If a visitor is logged in to your store, pass their identity to Reevix to enable cross-session personalization and accurate returning visitor detection:
rvx('identify', {
userId: 'usr_12345', // your internal user ID
email: 'shopper@example.com', // optional
purchaseCount: 3, // optional; used for returning buyer segmentation
})
Privacy note: The email address is hashed before storage. It is never sent to third-party services.
Events Fired by the SDK
Subscribe to internal SDK events:
rvx('on', 'stateChange', function(newState, prevState) {
console.log('Shopper moved from', prevState, 'to', newState)
})
rvx('on', 'intentSurveyAnswer', function(answer) {
// answer: 'exploring' | 'comparing' | 'price_concern' | 'need_help' | 'ready'
if (answer === 'price_concern') {
// Fire your own promo logic
}
})
rvx('on', 'interventionShown', function(template) {
// template: { id, type, painPoint, message }
})
Debug Mode
Add ?rvx_debug=1 to any page URL to enable the SDK debug overlay. It shows:
- Current behavioral state and confidence score
- All signals currently active
- The last intervention shown (if any)
- Raw event stream
Remove the query parameter to disable debug mode.