Include the SDK
Add the following <script> tag inside your HTML’s <head> (or just before </body>) to load the Experro Analytics library:
<script>
window.ExpConfigs = {
analyticsUrl: 'https://YOUR_BASE_URL/analytics-service/v1',
tenantId: 'YOUR_TENANT_ID',
workspaceId: 'YOUR_WORKSPACE_ID',
envId: 'YOUR_ENV_ID',
channelId: 'YOUR_CHANNEL_ID',
channelLocale: 'YOUR_CHANNEL_LOCALE',
currency: 'YOUR_CURRENCY'
}
const script = document.createElement("script");
script.src = "https://cdn22.myexperro.com/experro-analytics-library/analytics-sdk-v1.min.js";
document.head.appendChild(script);
</script>
Once the script is loaded and ready, it dispatches an exp-analytics-loaded event on both the document and window objects. You can listen to this event to begin tracking analytics events.
document.addEventListener('exp-analytics-loaded', function() {
console.log('Experro Analytics SDK is ready!');
// Proceed with initialization or tracking
});
- Placing it in <head> ensures tracking begins as soon as possible.
- If you’re concerned about page‑render performance, you can move it just before </body>, but make sure your initialization code runs after the script has loaded.
Prerequisites
Before initializing the SDK, you’ll need the following from the Experro admin panel:
-
Tenant ID (
tenantId)
Your unique identifier for billing and data partitioning.
-
Workspace ID (
workspaceId)
Choose or create a workspace to segment events by functional area.
-
Environment ID (
environmentId)
Use distinct values (e.g. dev, staging, prod) to isolate test data from production.
-
Channel ID (
channelId)
Typically "web", but you can define custom channels (e.g. "mobile-web", "kiosk-app").
-
Language / Locale (
language)
A locale code (e.g. "en-US", "fr-FR") to help you segment by user region.
Make sure you have these five values handy in your application’s configuration before moving on to next step.