Beacon API Docs
  • Beacon - Installation
  • Beacon - Usage
    • Beacon Usage - Overview
    • Usage in a Next.js Environment
    • Open and Close Programmatically
  • Native Routing in Beacon
    • Vanilla JS - Native Routing Example
    • React JS - Native Routing Example
    • Vue JS - Native Routing Example
    • Angular JS - Native Routing Example
  • Loading User Data into BeaconBar
  • Loading Session Data into Beacon Bar
  • Callbacks in Beacon
    • Add Callbacks in Beacon
    • Remove Callbacks in Beacon
    • React Example for Callbacks
  • Trigger smart journeys From Your App
  • Execute Command From Your App
  • Open Help Docs From Your App
  • Emitting Events to Beacon
  • Listening to events from Beacon Bar
    • Adding event listeners in Beacon
    • Removing event listeners in Beacon
    • React Example for Event Listeners in Beacon
  • List of events emitted by Beacon Bar
  • Implementing Content Security Policy (CSP) for Beacon Integration
Powered by GitBook
On this page
  1. Beacon - Usage

Beacon Usage - Overview

Importing beacon

import the beacon module in the same way as in a regular JavaScript environment:

import { Beacon } from '@beacon.li/bar';

Loading Beacon

To load beacon in your application, use the Beacon.load method and pass your organization ID as a parameter. Replace 'ORG_ID' with your actual organization ID:

Beacon.load('ORG_ID');

If you want to use a <script> tag instead, then you can try as below. Replace your ORG_ID with your actual organization ID

<script>
(function(b,e,a,c,o,n) {b[c] = {orgId:n, open:()=>{b[c].opened=true}};
  var s = e.createElement(a);
  s.src='https://cdn.beacon.li/sdk/latest.js';s.async=true;s.type='module';
  var d = e.createElement(o);
  d.id='beacon-user';
  e.body.appendChild(d);
  e.head.appendChild(s);
})(window, document, 'script', 'BeaconBar', 'div','ORG_ID');
</script>

To get your organization ID, go to beacon dashboard, open beacon bar using CMD/Ctrl + K and search for 'Copy Org ID'

PreviousBeacon - UsageNextUsage in a Next.js Environment

Last updated 1 year ago