Spara Documentation
  • Overview
    • What is Spara?
    • How can Spara help?
  • Channels
    • AI Chat: Smartbar, Navigator & Fullscreen
      • Spara Smartbar
      • Spara Navigator
      • Spara Fullscreen
    • AI Email
    • AI Phone Calls
  • Platform
    • Leads
    • Journeys
    • Analytics
    • Library & AI Training
    • Testing
  • Installation Guide
    • Installing Spara Chat
      • Installing Spara Smartbar
      • Installing Spara Navigator
      • Installing Spara Fullscreen
      • Installing Spara on Webflow
    • Query Parameters
    • JavaScript Events
  • Installation FAQ
  • Integrations
    • Salesforce
    • Hubspot
    • Marketo
    • Slack
    • Chili Piper
    • Calendly
    • Outreach
  • Other
    • Security & Compliance
Powered by GitBook
On this page
  1. Installation Guide

JavaScript Events

How to leverage JavaScript events exposed by Spara.

Spara's JavaScript embed snippet exposes two events to the DOM:

  • Spara.onSparaLoad() fires when Spara's embed script finishes executing

  • Spara.onUserMessageSent() fires when a lead sends message to Spara

These can be used however you like. For example, by pushing these events to your window's data layer for ingestion by Google Analytics.

To access these Javascript events, you will need to add an additional script to your website's <head>:

<script type="text/javascript" src="https://app.spara.co/embed-<app_id>.js"></script>
<script>
  Spara = {
    onSparaLoad: () => {
        console.log("Spara is loaded! 🎬");
    },
    onUserMessageSent: () => { 
        console.log("User sent a message to Spara 💬");
    },
  }
</script>

Last updated 1 month ago