Skip to main content

Event System

The Glood SDK’s event system automatically transforms Shopify Analytics events into Glood event data and transmits them to the versioned headless events API with full privacy compliance.
Events are routed by the client’s configured version off the recommendations app’s main endpoint — they are no longer sent to a separate events.glood.ai host. See Event Destination below.

Architecture Overview

The event system follows this flow:

Components

  1. Event Subscription - Automatically subscribes to Shopify Analytics events
  2. Event Distribution - Routes events to interested apps
  3. Data Transformation - Converts Shopify data to Glood pixel format
  4. Consent Checking - Verifies customer privacy permissions
  5. Pixel Queue - Manages immediate transmission with retry logic
  6. Error Handling - Comprehensive error handling and logging

Event Types

The SDK tracks these Shopify Analytics events:

Core Events

Commerce Events

Attribution Events (Custom)

Unlike the standard events above (which are fully automatic), attribution events are sent by calling the track helpers when a visitor interacts with a recommendation section. They use event.type: 'custom' and carry the interaction details in event.customData.track: Attribution events flow through the same versioned events API as standard events (see Event Destination) — on a v3 client they POST to /api/storefront/v3/headless/events with event.type: 'custom'. See the Recommendations API for the SectionTrack payload shape.

Event Transformation

The SDK transforms Shopify Analytics events into Glood pixel format using sophisticated data transformation:

Shopify → Glood Transformation

The experience field carries the A/B experience id assigned by the recommendations API. The SDK persists it to localStorage (key gai_s_e) after every sections fetch, and every event includes it automatically — this is how analytics segment by experience. It is null until the first sections fetch.

Event-Specific Transformations

Product Viewed

Cart Viewed

Event Destination

Events (both the automatic standard events and the custom attribution events) are routed by the client’s configured version off the recommendations app’s main endpoint (default https://storefront.glood.ai). There is no separate events host.
Headers
Payload — the headless events schema:
Need to send a v3 event manually (outside the automatic analytics flow)? Use sendHeadlessEvent(options, params) or the recommendations app’s sendEvent(params) — both POST to /api/storefront/v3/headless/events.

Event Transmission

Immediate Transmission

The SDK uses immediate transmission with retry logic:

Retry Strategy

  • Retry Delays: [1000, 2000, 4000, 8000] milliseconds
  • Max Retries: 4 attempts total (initial + 3 retries)
  • Backoff: Exponential backoff strategy
  • Error Logging: Comprehensive error logging with debug details

Network Resilience

The SDK automatically checks customer consent before sending pixels:

Privacy Scenarios

Session & Identity Management

Identity is stored in cookies (CookieStorage). The cookie key names are:

Client ID Generation

Session Management

Debug Logging

Debug Mode Events

Enable debug mode to see detailed event flow:

Debug Log Examples

Error Debug Logs

Performance Considerations

Event Deduplication

Events are subscribed to only once per event type:

Immediate Transmission

No batching delays - events are sent immediately:

Memory Management

  • No accumulation - Events are not stored in memory
  • Immediate processing - Events are transformed and sent immediately
  • Cleanup - Event handlers are properly cleaned up on unmount

Error Handling

Network Errors

Transformation Errors

Custom Event Handling

Accessing Raw Events

Custom Data Enrichment

Best Practices

1. Debug Mode in Development

2. Monitor Network Errors

4. Test Event Flow

See Also