Skip to main content

Web Quickstart

caution

The Web SDK is currently in Closed Beta testing. The public API and internal operations are subject to change while it is tested with qualified partners and in different web-technology environments.

Version: 1.7.0

Requirements

Browsers

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE11

Nodejs

  • 6.12+
  • requires an isomorphic fetch polyfill (eg: node-fetch)

1. Installing the SDK

Add the supplied lmgSDK.js file to your repository

The file is a Universal Module Definition so it can be used two ways:

a) Run-time

<!-- HTML -->
<script src="/vendor/lmgSDK.js"></script>

Exposes window.loopmediagroup.Client constructor

b) Compile-time

const Client = require('./vendor/lmgSDK').Client;

2. Initialization

Create an Integration Write Key

Create a new Integration for your app in the Property you're working with, and use the Integration Write Key to initialize the SDK (below).

See Enabling SDK Integrations for more details.

Initialize the SDK

The SDK must be initialized first thing, before calling any other methods.

const lmgClient = new Client(
INTEGRATION_WRITE_KEY,
{
useGeolocation: false,
logLevel: 'Debug'
}
);

Configuration

ParameterTypeDefaultUse
useGeoLocationbooleantrueShould we ask the browser for the user's physical location?
useWindowbooleantrueSet to false when running in a node environment
fetchFunctionwindow.fetchFetch implementation to use for http requests. Required if running in nodejs
logLevelstring'Warning'Level of events to log to the console.

LogLevel Values

ValueMeaning
'Verbose'Fine-grained information events. Used for debugging and should never be displayed in production.
'Info'Course application information that may be useful for debugging or in production logs.
'Warning'Non-critical errors that were recovered from or have few major problems.

3.Testing your integration

Run app. You should see following message in your log:

[RefreshOrCreateSession] Completed successfully

Note: This will only be logged when logLevel is set to 'Debug' or 'Verbose'

Next Steps