Skip to main content

Analytics Events

The Hubble SDK emits analytics events as users navigate and interact with the gift card store. These events allow you to track user behavior in your analytics system (Mixpanel, CleverTap, Amplitude, etc.) and build funnels, cohorts, and reports around gift card engagement.

How to Listen for Events

To receive events from the SDK, you will need to register an event listener. Please refer to the platform-specific integration guides for detailed instructions on how to implement this:

How Events Work?

Events are sent via the same mechanism as action events. They have a type of "analytics" and include an event name and a properties object. Here is the structure:

{
"type": "analytics",
"event": "payment_success",
"properties": {
"amount": 500,
"referenceId": "ord_123",
"provider": "RAZORPAY"
}
}

Setting Up Event Tracking

Add analytics event handling alongside the action event listener you set up in Part III:

window.addEventListener("message", function (event) {
if (event.data.type === "action") {
// Handle action events (app_ready, close, error) as before
}

if (event.data.type === "analytics") {
const eventName = event.data.event;
const properties = event.data.properties || {};

// Send to your analytics provider
analytics.track(eventName, properties);

// Log critical events for debugging
if (["payment_success", "payment_fail", "voucher_generation_fail"].includes(eventName)) {
console.log("Critical SDK event:", eventName, properties);
}
}
});

Key Events to Track

Go through this document to see the latest analytics events:

Analytics Events Reference

Native Platform Event Handling

On native platforms, events come through the same JavaScript bridge as action events. The event structure is identical. Filter events by their type field:

  • Android: In your @JavascriptInterface handler's onAnalyticsEvent method, you receive the event name and properties as separate parameters. Forward these to your analytics SDK.
  • iOS: In your WKScriptMessageHandler, check if type == "analytics" and extract the event and properties fields from the JSON.
Common Issue: Events Not Reaching Analytics

If you are not seeing SDK events in your analytics dashboard, check the following:

  1. Verify your event listener is set up BEFORE loading the SDK (events fire immediately on load).
  2. On native platforms, ensure the JavaScript bridge is registered before the WebView loads the URL.
  3. Check for CORS issues if your analytics provider requires domain whitelisting - some partners needed to whitelist the Hubble SDK domain.
  4. On iOS, events sent via WKScriptMessageHandler are delivered on the main thread. If your analytics call blocks the main thread, events may be dropped.
Build a Monitoring Dashboard

Track the ratio of payment_initiated to payment_success events to monitor your payment success rate. A sudden drop in this ratio can indicate payment gateway issues, UPI configuration problems, or SDK integration bugs. Setting up an alert on this metric is one of the highest-value monitoring actions you can take.