Quick Guide: Adding and Initializing the Analytics SDK
This page explains how to add and initialize the Global-e Analytics SDK on your website. Use this guide if you are not already using the Global-e Client SDK in your integration.
Note
This guide is intended only for merchants who are not using the client-side SDK in their Global-e integration. Please note that this is not the standard Global-e integration method.
Overview
The Analytics SDK lets you track browsing activity for shoppers by sending analytics events to Global-e. The SDK must be loaded and initialized on every page where you want to capture events. After initialization, you must immediately send the BrowsingStart
event.
Implementation Steps
Add the Analytics SDK script to the
<head>
section of your site. Use the/PROD/
path for production, and/QA-INT/
or/STG/
for testing or development.Immediately after the script, add the initialization code, replacing the placeholder values with your own:
merchantId: your unique merchant identifier provided by Global-e.
shopperCountryCode: the two-letter ISO 3166-1 Alpha-2 country code of the shopper, updated dynamically from your country selector.
cdnUrl: the Global-e environment URL. For production use
https://webservices.global-e.com/
, and for development useconnect.bglobale.com
(QA-INT) orconnect2.bglobale.com
(STG).
After initialization, immediately call
sendBrowsingStartEvent()
. This step is critical for tracking user activity and must be repeated on every page load.
Example Implementation
<!DOCTYPE html> <html> <head> <script src="https://globale-analytics-sdk.global-e.com/PROD/bundle.js"></script> <script> // This function initializes the Global-e Analytics SDK async function initializeGEAnalytics() { try { const sdk = new AnalyticsSDK(); // Replace the placeholder values below const merchantId = 'YOUR_MERCHANT_ID'; const shopperCountryCode = 'ZZ'; // ISO 3166-1 Alpha-2 const cdnUrl = 'https://webservices.global-e.com/'; // Production URL await sdk.init(merchantId, shopperCountryCode, { cdn: cdnUrl, browser: window }); // After initialization, send the BrowsingStart event await sdk.sendBrowsingStartEvent(); } catch (error) { console.error('Analytics SDK Initialization Failed:', error); } } // Call the function initializeGEAnalytics(); </script> </head> <body> ... </body> </html>