Basic Setup Example
This example shows how to set up the Glood Hydrogen SDK with minimal configuration for a typical e-commerce store.Complete Implementation
1. Environment Variables
2. Root Layout (app/root.tsx)
3. Layout Component (app/components/Layout.tsx)
What This Setup Provides
✅ Automatic Event Tracking
The basic setup automatically tracks these events:- Page Views - All page navigation
- Product Views - Product detail page visits
- Collection Views - Category/collection browsing
- Cart Views - Shopping cart interactions
- Search Queries - Product search submissions
- Add to Cart - Product additions to cart
- Remove from Cart - Product removals from cart
✅ Privacy Compliance
Default consent requirements:- Recommendations: Analytics + Marketing consent
- Search: Analytics consent only
- Wishlist: Analytics + Preferences consent
✅ Default Endpoints
- Recommendations:
https://storefront.glood.ai
+https://events.glood.ai
- Search:
https://s-s.glood.ai
+https://s-pixel.glood.ai
- Wishlist:
https://w-s.glood.ai
+https://w-pixel.glood.ai
✅ Debug Logging
In development mode, you’ll see console logs like:Testing the Setup
1. Verify Installation
Check that the SDK is working by looking for debug logs in the browser console.2. Test Event Tracking
- Navigate to a product page - Should see
product_viewed
events - Search for products - Should see
search_submitted
events - Add item to cart - Should see
product_added_to_cart
events - View cart - Should see
cart_viewed
events
3. Verify Network Requests
In browser DevTools Network tab, look for successful POST requests to:https://events.glood.ai
https://s-pixel.glood.ai
https://w-pixel.glood.ai
Customizing the Basic Setup
Add Custom Settings
Selective App Usage
Environment-Specific Debug
Using the Glood Client
Access Client in Components
Custom Analytics Integration
Common Issues and Solutions
Issue: No Debug Logs
Check:- Debug mode is enabled:
debug: true
- Browser console is open
- Events are being triggered (navigate to product pages)
Issue: CSP Violations
Check:- All Glood domains are in
connectSrc
- CSP headers are being applied correctly
- No typos in domain names
Issue: No Network Requests
Check:- Customer consent is granted (try allowing all cookies)
- Pixel tracking is enabled (default:
enabled: true
) - Apps are properly registered with
.use()
Issue: TypeScript Errors
Solution:Next Steps
- Advanced Configuration - Custom endpoints and settings
- Privacy & Consent - GDPR/CCPA compliance
- Debugging Guide - Troubleshooting tips
- API Reference - Complete documentation