← Back to Dashboard

EmoraTest Documentation

SDK Documentation

Complete guide to installing and using EmoraTest on your website.

Getting Started

EmoraTest detects user emotions from behavior patterns and helps you optimize conversions. Add one script to your site to start tracking sessions, emotions, and run A/B tests.

What you'll need:

  • • Your SDK Key — found in Settings → SDK & Integration
  • • Your Server URL — e.g., https://your-emoratest-server.com

Installation

Add this script tag before the closing </body> tag on every page you want to track:

html
<script src="https://YOUR_SERVER/static/sdk/emoratest.umd.js"></script>
<script>
  EmoraTest.init({
    sdkKey: "YOUR_SDK_KEY",
    apiUrl: "https://YOUR_SERVER"
  });
</script>

Note: Replace YOUR_SDK_KEY with the key from your Settings page. Replace YOUR_SERVER with your EmoraTest server URL.

The SDK automatically handles session persistence across pages — no additional code needed.


What Gets Tracked Automatically

Once installed, the SDK automatically tracks all user behavior signals:

🖱️

Mouse movements

Every cursor movement tracked

👆

Clicks

All clicks with element IDs

📜

Scroll behavior

Scroll depth and patterns

😤

Rage clicks

Rapid clicking = frustration

🚪

Exit intent

Cursor to close button

↕️

Scroll retreats

Back-and-forth scrolling

⏱️

Session duration

Time spent on page

📄

Page URLs

Navigation tracking

No extra code needed! Just install and the dashboard will start showing session data, emotion predictions, and behavior signals.


Tracking Conversions

To measure what matters, tell EmoraTest when a user converts (makes a purchase, signs up, completes a goal).

javascript
// Call this when a user completes your goal action
// For example, after a purchase:
document.getElementById('buy-button').addEventListener('click', function() {
  EmoraTest.track('purchase', { value: 49.99 });
});

// For a signup:
document.getElementById('signup-form').addEventListener('submit', function() {
  EmoraTest.track('signup');
});

// Custom conversion:
document.getElementById('contact-form').addEventListener('submit', function() {
  EmoraTest.track('contact', { plan: 'premium' });
});

The first argument is the event name. Use 'purchase' for e-commerce conversions. You can use any name for custom goals.


Running A/B Tests

EmoraTest includes a full-featured A/B testing platform. Create flags, assign variants, and track which version performs better.

Step 1: Create a Feature Flag

  1. Go to Feature Flags in the dashboard
  2. Click New Flag
  3. Enter a key (e.g., hero-headline) and name
  4. Add 2 variants: control (50%) and variant_b (50%)
  5. Click Activate

Step 2: Use the Flag in Your Code

On the page you want to test, evaluate the flag and show different content:

javascript
// Wait for the SDK to evaluate the flag
async function setupABTest() {
  const result = await EmoraTest.evaluateFlag('hero-headline');

  if (result.variant === 'control') {
    // Original version
    document.getElementById('headline').textContent = 'Welcome to Our Store';
  } else if (result.variant === 'variant_b') {
    // New version to test
    document.getElementById('headline').textContent = 'Shop the Best Deals Today';
  }
}

setupABTest();

Step 3: Track Conversions

Make sure you have EmoraTest.track('purchase') on your conversion page (see Section 4 above).

Step 4: Check Results

Go to Feature Flags → click View Results on your flag. You'll see how many visitors saw each variant and which one converts better.

How it works: Each visitor automatically gets assigned one variant and always sees the same one. The SDK handles this deterministically — you don't need to manage user assignments.


A/B Test Examples

Test Button Color

javascript
const result = await EmoraTest.evaluateFlag('cta-button-color');
const button = document.getElementById('cta-button');

if (result.variant === 'variant_b') {
  button.style.backgroundColor = '#FF6B00';
  button.textContent = 'Buy Now — Free Shipping';
}

Test Entire Page Sections

javascript
const result = await EmoraTest.evaluateFlag('pricing-layout');

if (result.variant === 'control') {
  document.getElementById('pricing-v1').style.display = 'block';
  document.getElementById('pricing-v2').style.display = 'none';
} else {
  document.getElementById('pricing-v1').style.display = 'none';
  document.getElementById('pricing-v2').style.display = 'block';
}

Test with More Than 2 Variants

Create a flag with 3 variants (control 34%, variant_b 33%, variant_c 33%) and use a switch statement:

javascript
const result = await EmoraTest.evaluateFlag('hero-variant');
const hero = document.getElementById('hero');

switch (result.variant) {
  case 'control':
    hero.innerHTML = '<h1>Welcome</h1><p>Start your journey</p>';
    break;
  case 'variant_b':
    hero.innerHTML = '<h1>Join 10,000+ Customers</h1><p>Limited time offer</p>';
    break;
  case 'variant_c':
    hero.innerHTML = '<h1>Free Shipping Today</h1><p>Use code: FREESHIP</p>';
    break;
}

Understanding Your Dashboard

The EmoraTest dashboard gives you deep insights into user behavior and emotions.

📊

Sessions

Every user visit. Shows emotion detected, friction score, abandonment risk, and user intent.

📊

Why-Analysis

Connects emotions to conversions. Shows which emotions lead to purchases and which cause drop-offs. Use this to understand WHY users leave.

📊

Heatmap

Visual display of where users click, scroll, and move. Shows dominant emotion per page element.

📊

Feature Flags

Your A/B tests. Create flags, assign variants, track which version performs better.

📊

Emotion Analysis

Each session gets an emotion prediction (frustration, delight, confusion, anxiety, etc.) based on mouse behavior patterns. 86%+ accuracy.


SDK Reference

Complete reference of all available EmoraTest SDK methods.

MethodDescription
EmoraTest.init({ sdkKey, apiUrl })Initialize the SDK. Call once per page load.
await EmoraTest.evaluateFlag(flagKey)Get assigned variant for an A/B test. Returns { variant: string, enabled: boolean }.
EmoraTest.track(eventName, properties?)Track a custom event like purchase, signup, etc.
EmoraTest.getSessionId()Get the current session ID.
EmoraTest.getVisitorId()Get the persistent visitor ID.

Troubleshooting

Common issues and how to fix them.

SDK not loading

Check that the script src URL is correct and your server is running. Open browser DevTools Console to see error messages.

401 errors in console

Your SDK key is invalid. Go to Settings → SDK & Integration and copy the current key.

Sessions not appearing in dashboard

Check browser console for errors. Make sure apiUrl points to your EmoraTest server (e.g., http://localhost:8000 for local testing).

A/B test always shows the same variant

This is correct! Each visitor always gets the same variant for consistency. Open an incognito window to see the other variant.

Emotion showing as 'Analyzing...'

The emotion model runs when the session ends. Wait for the user to leave the page or close the tab. Results appear within 30 seconds.

Questions? Email [email protected]