### Complete iOS SDK Integration Example Source: https://documentation.bloomreach.com/data-hub/docs/configure-ios-sdk-with-jwt-authentication This example demonstrates the recommended setup order for a complete stream/Data hub integration using JWT authentication. It includes configuring the SDK, registering a JWT error handler, and providing the initial JWT token. ```swift import ExponeaSDK // 1. Configure with StreamSettings Exponea.shared.configure( Exponea.StreamSettings( streamId: "YOUR_STREAM_ID", baseUrl: "https://api.exponea.com" ), pushNotificationTracking: .enabled(appGroup: "YOUR_APP_GROUP") ) // 2. Register JWT error handler BEFORE setting the token Exponea.shared.setJwtErrorHandler { context in switch context.reason { case .expiredSoon: yourBackend.fetchNewJwt(for: context.customerIds) { newToken in Exponea.shared.setSdkAuthToken(newToken) } case .expired, .notProvided, .invalid: yourBackend.fetchNewJwt(for: context.customerIds) { newToken in Exponea.shared.setSdkAuthToken(newToken) } default: break } } // 3. Provide the initial JWT token Exponea.shared.setSdkAuthToken("YOUR_INITIAL_JWT_TOKEN") // 4. (Optional) Identify the customer with bundled JWT let identity = CustomerIdentity( customerIds: ["registered": "user@example.com"], jwtToken: "YOUR_INITIAL_JWT_TOKEN" ) Exponea.shared.identifyCustomer(context: identity, properties: [:], timestamp: nil) ``` -------------------------------- ### Product Title Example Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-title Provides an example of a product title string. This attribute should not be empty. ```json "Classic Fit Cotton T-Shirt" ``` ```json "Classic Fit Cotton T-Shirt - Black - Small" ``` -------------------------------- ### Product Height Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-height These examples show the expected numeric format for the product height attribute. ```json 72.0 ``` ```json 35.5 ``` ```json 6.25 ``` ```json 180.0 ``` -------------------------------- ### Example Product Colors Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-color These examples show the expected format for the 'color' attribute, which should be a specific, detailed color name. ```json "Navy Blue" ``` ```json "Gray" ``` ```json "Rose Gold" ``` -------------------------------- ### Product Width Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-width These examples demonstrate the numeric values that can be assigned to the 'width' attribute. The units are context-dependent. ```json 24.5 ``` ```json 60.0 ``` ```json 15.75 ``` ```json 120.0 ``` -------------------------------- ### Example Product Depth Values Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-depth These examples show valid numeric values for the product depth attribute. ```json 20.0 ``` ```json 45.5 ``` ```json 12.75 ``` ```json 90.0 ``` -------------------------------- ### Product Description with Specifics Example Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-description Example of a product description specifying color and size, with details on fit and colorfastness. ```json "Our Classic Fit Cotton T-Shirt in timeless black, size medium. This colorway offers maximum versatility and pairs effortlessly with any outfit. Fits true to size with a chest measurement of 38-40 inches. The deep black color is specially treated to resist fading even after multiple washes." ``` -------------------------------- ### Example Product Flags Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-flags Illustrates common examples of product flags used for categorization and filtering. ```json ["new-arrival", "sale", "bestseller"] ``` ```json ["eco-friendly", "organic", "sustainable"] ``` ```json ["exclusive", "limited-edition", "clearance"] ``` ```json ["featured", "staff-pick", "trending"] ``` -------------------------------- ### Initialize and start the Bloomreach tracking snippet Source: https://documentation.bloomreach.com/data-hub/docs/sdk-integration-for-a-new-engagement-setup This snippet initializes the Bloomreach tracking object with configuration options and then starts the tracking service. Ensure `brweb.start()` is called only after visitor consent for privacy regulations. ```javascript brweb.init({ new_experiments: { mode: "sync" }, customer: { email_id: "customer@example.com" // Identified visitor's email address }, track: { default_properties: { customer_tier: "gold-member" // Custom properties added to all events }, metadata: { domain_key: "Pacific", // Provided by your Discovery consultant view_id: "en_US", // Provided by your Discovery consultant test_data: true, // Ignores events in Discovery on production debug: true // Enables real-time integration mode in Discovery } }, }); brweb.start(); ``` -------------------------------- ### Product Size Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-size Examples of common string formats for the size attribute, including alphabetic, numeric, and descriptive values. ```json "Medium" ``` ```json "XL" ``` ```json "9.5" ``` ```json "32x34" ``` -------------------------------- ### Example Swatch Image URL Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-swatch-image Provides an example of a valid, absolute URL for a swatch image. The URL should point to an image resource, preferably using HTTPS. ```json "https://cdn.example.com/products/swatches/shirt-navy-swatch-50x50.jpg" ``` ```json "https://images.store.com/catalog/2024/variant_12345_swatch.webp" ``` ```json "https://assets.store.com/swatches/fabric-pattern-floral-blue.png" ``` -------------------------------- ### Supplier Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-supplier Examples of valid string values for the supplier attribute, including names and IDs. ```json "Acme Corporation" ``` ```json "SUP-12345" ``` ```json "Global Textiles Inc" ``` ```json "VENDOR-789" ``` -------------------------------- ### Example Thumbnail Image URL Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-thumb-image Provides an example of a valid, absolute URL for a product thumbnail image. This URL should point to a publicly accessible image resource, preferably using HTTPS. ```json "https://cdn.example.com/products/shoes/running-shoe-blue-300x300.jpg" ``` ```json "https://images.store.com/catalog/2024/product_12345_thumb.webp" ``` -------------------------------- ### Example Discount Percentages Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-discount-percentage These examples show valid float values for the discount_percentage attribute. The value must be between 0 and 100. ```json 25.0 ``` ```json 33.33 ``` ```json 10.5 ``` -------------------------------- ### Add Tracking Snippet and Start SDK Source: https://documentation.bloomreach.com/data-hub/docs/sdk-integration-for-new-engagement-and-discovery-setups Add this snippet to your website to enable tracking and start the Bloomreach SDK. Ensure `brweb.start()` is called after cookie consent is granted. ```javascript brweb.init({ new_experiments: { mode: "sync" }, customer: { email_id: "customer@example.com" // Identified visitor's email address }, track: { default_properties: { customer_tier: "gold-member" // Custom properties added to all events }, metadata: { domain_key: "Pacific", // Provided by your Discovery consultant view_id: "en_US", // Provided by your Discovery consultant test_data: true, // Ignores events in Discovery on production debug: true // Enables real-time integration mode in Discovery } }, }); brweb.start(); ``` -------------------------------- ### Product Condition Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-condition These examples show common string values for the product condition attribute. Use these to categorize products based on their state. ```json "new" ``` ```json "used" ``` ```json "refurbished" ``` ```json "open-box" ``` -------------------------------- ### Example Lead Time Values Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-lead-time These examples show typical string representations for the lead time attribute, indicating the number of days required for restocking. ```json "7" ``` ```json "14" ``` ```json "30" ``` ```json "3" ``` -------------------------------- ### Example Review Scores Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-reviews These examples demonstrate the expected format for the 'Reviews' attribute, which should be a floating-point number representing an aggregated customer rating. ```json 4.5 ``` ```json 3.8 ``` ```json 5.0 ``` ```json 2.3 ``` -------------------------------- ### Example Large Image URL (JSON) Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-large-image Provides an example of a valid, absolute URL for a large product image, typically in JPEG format. Ensure URLs are publicly accessible and use HTTPS. ```json "https://cdn.example.com/products/shoes/running-shoe-blue-1200x1200.jpg" ``` -------------------------------- ### API Request Example: Tracking a Purchase Event Source: https://documentation.bloomreach.com/data-hub/reference/tracking-api-overview This example demonstrates how to track a `purchase` event using the Tracking API. It includes essential fields like `customer_ids`, `type`, `properties`, and `metadata`, with `_br_uid_2` being crucial for server-side purchase tracking. ```APIDOC ## API Request Example: Purchase Event ### Description This example tracks a `purchase` event using server-side tracking. The `metadata` block includes `_br_uid_2`, which is required when tracking purchases server-side. The Bloomreach Web SDK adds this automatically for browser-side tracking, but your server must explicitly pass it. ### Request Body ```json { "commands": [ { "name": "customers/events", "data": { "customer_ids": { "email_id": "customer@example.com" }, "type": "purchase", "properties": { "purchase_id": "ID123", "purchase_status": "created", "total_price": 107.72, "local_currency": "EUR", "price_local_currency": 99.98, "product_list": [ { "title": "Yellow wide sweater with turtleneck", "product_id": "119479", "variant_id": "MJ12199-0400", "price": 53.86, "price_local_currency": 49.99, "quantity": 2 } ], "location": "https://www.pacific.com/en/order_complete", "referrer": "https://www.pacific.com/en/checkout" }, "metadata": { "_br_uid_2": "uid=7080827054609:v=cde-v3.38.0:ts=1741771054202:hc=6", "domain_key": "Pacific", "view_id": "en_US" }, "timestamp": 1749545984.278 } } ] } ``` ``` -------------------------------- ### Single Price Point Example Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-price-range Set the minimum and maximum values to be the same when a product has a single fixed price. ```json [29.99, 29.99] ``` -------------------------------- ### Update Items and Destinations Source: https://documentation.bloomreach.com/data-hub/reference/update_records This example shows how to update items and then synchronize these changes to destinations. ```APIDOC ## Update Items and Destinations ### Description Used with `update-records` to update items and sync to destinations. ### Method POST ### Endpoint /update-records ### Request Body - **actions** (array) - Required - A list of actions to perform. For this case, it should be `["update-items", "update-destination-items"]`. ### Request Example ```json { "actions": [ "update-items", "update-destination-items" ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Example Returned Products Count Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-returned-products Represents a count of returned products. This value should be a whole number. ```json 5 ``` ```json 0 ``` ```json 23 ``` ```json 150 ``` -------------------------------- ### OpenAPI Definition for Get Server Time Source: https://documentation.bloomreach.com/data-hub/reference/get_system-time This OpenAPI definition outlines the GET endpoint for retrieving the current server time. It specifies the request parameters, response structure, and example responses for success and unauthorized access. ```json { "openapi": "3.0.3", "info": { "title": "Unified Tracking", "version": "1.0" }, "servers": [ { "url": "https://unt.api.exponea.dev/track/u/v1/", "description": "UNT Dev instance" }, { "url": "https://cloud-api.exponea.com/track/u/v1/", "description": "Cloud instance" } ], "components": { "parameters": { "streamIDParam": { "in": "query", "name": "stream_id", "required": true, "schema": { "type": "string" }, "description": "Data stream identifier" } }, "schemas": { "basicResult": { "type": "object", "required": [ "success" ], "properties": { "success": { "description": "Whether the command was processed successfully", "type": "boolean" }, "error": { "description": "Error message if the command was not processed successfully", "type": "string" }, "errors": { "description": "List of errors that occurred while processing the command", "type": "array", "minItems": 0, "items": { "type": "string" } }, "command_id": { "description": "Identifier of the command, if provided in the request", "type": "string" } } } } }, "paths": { "/system/time": { "get": { "summary": "Get current server time", "description": "Returns the current server time as a UNIX timestamp", "parameters": [ { "$ref": "#/components/parameters/streamIDParam" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/basicResult" }, { "type": "object", "properties": { "time": { "description": "Current server time as UNIX timestamp", "type": "number" } } } ], "example": { "success": true, "errors": [], "time": 1743067286.5573673 } } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/basicResult" } ], "example": { "success": false, "error": "access key not provided" } } } } } } } } }, "x-readme": { "explorer-enabled": true, "proxy-enabled": true } } ``` -------------------------------- ### Example Launch Date with Time Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-launch-date Represents a specific date and time in UTC, including hours, minutes, and seconds. ```json "2024-03-15T10:30:00Z" ``` -------------------------------- ### OpenAPI Definition Example Source: https://documentation.bloomreach.com/data-hub/reference/get_job This is an example snippet from the OpenAPI definition. ```json { "success": true, "details": [] } } } }, "x-readme": { "explorer-enabled": true, "proxy-enabled": true } } ``` -------------------------------- ### Brand Name Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-brand These examples show common string values for the brand attribute. ```json "Nike" ``` ```json "Adidas" ``` ```json "Apple" ``` -------------------------------- ### Install Bloomreach Web SDK Source: https://documentation.bloomreach.com/data-hub/docs/bloomreach-web-sdk Add this snippet to the `` of your HTML before any other scripts. Replace placeholder values with your actual credentials. For Google Tag Manager, use ` ``` -------------------------------- ### Initialize Bloomreach Web SDK Source: https://documentation.bloomreach.com/data-hub/docs/bloomreach-web-sdk Configure and start the Bloomreach Web SDK. Ensure `brweb.start()` is called after cookie consent is obtained, as required by some privacy regulations. ```javascript const brweb = new br.Web({ // Required: The ID of the view to use for this website. view_id: "en_US", // Optional: Set to true to enable test data in Discovery. test_data: true, // Optional: Set to true to ignore events in Discovery on production. debug: true // Optional: Enables real-time integration mode in Discovery }); brweb.start(); ``` -------------------------------- ### Product Description Example Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-description Example of a detailed product description for a t-shirt, highlighting material, fit, and durability. ```json "Experience ultimate comfort with our Classic Fit Cotton T-Shirt. Made from 100% organic cotton, this versatile wardrobe essential features a relaxed fit that flatters every body type. The premium ring-spun cotton fabric is pre-shrunk and features reinforced shoulder seams for lasting durability. Perfect for casual wear, layering, or everyday comfort. Machine washable and fade-resistant." ``` -------------------------------- ### Web SDK Installation with JWT Authentication Source: https://documentation.bloomreach.com/data-hub/docs/jwt-authentication-for-web-sdk Configure the Web SDK with an auth object containing an initial token and a callback for refreshing the JWT. The SDK uses the initial token on page load and the callback to obtain new tokens when requests fail with a 401 error. ```javascript async function getJwtFromBackend() { const response = await fetch('https://your-backend.com/api/get-jwt', { credentials: 'include' // Include session cookies }); const data = await response.json(); return data.token; } ``` ```javascript !function(e,t,n,i,o,r){ // ... standard brweb snippet bootstrap ... }(document,"brweb","script","webxpClient",window,{ target: "https://api.exponea.com", stream_id: "40494d18-e714-4c8c-bbd9-35225de4e81d", auth: { // Initial JWT token available when page loads token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', // Callback SDK uses to get fresh token when needed update_jwt_token: async () => { return getJwtFromBackend(); } }, // ... other configuration options }); brweb.start(); ``` -------------------------------- ### Example Color Group Values Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-color-group These are examples of normalized color family names that can be used for the 'color_group' attribute. ```json "Red" ``` ```json "Blue" ``` ```json "Green" ``` ```json "Neutral" ``` -------------------------------- ### Example Keywords List for Running Shoes Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-keywords This JSON snippet demonstrates a typical list of keywords for a product related to running shoes, including synonyms and related terms. ```json ["running", "shoes", "sneakers", "trainers", "athletic", "footwear", "jogging"] ``` -------------------------------- ### Discovery Price Mapping Example (With Sale) Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-price Illustrates how Discovery maps 'price' and 'original_price' when both are present. 'price' becomes 'sale_price' and 'original_price' becomes 'price' in Discovery. ```text Your data: price=19.99, original_price=29.99 Discovery sees: sale_price=19.99, price=29.99 ``` -------------------------------- ### Product URL Example Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-url Represents a canonical URL for a product. Absolute URLs are preferred for best application compatibility. ```json "https://example-store.com/products/classic-cotton-tshirt" ``` -------------------------------- ### Capacity Attribute Examples Source: https://documentation.bloomreach.com/data-hub/docs/items-system-attributes-product-capacity These examples show the numeric values that the Capacity attribute can hold, representing various measurements of storage, volume, or holding capacity. ```json 256.0 ``` ```json 1.5 ``` ```json 32.0 ``` ```json 2000.0 ``` -------------------------------- ### Configure and Start Bloomreach Tracking Snippet Source: https://documentation.bloomreach.com/data-hub/docs/sdk-integration-for-a-new-discovery-setup Configure the Bloomreach tracking snippet with customer information, default properties, and metadata. Ensure `brweb.start()` is called after cookie consent is granted. ```javascript brweb.init({ new_experiments: { mode: "sync" }, customer: { email_id: "customer@example.com" // Identified visitor's email address — optional for Discovery-only setups }, track: { default_properties: { customer_tier: "gold-member" // Custom properties added to all events, used for Discovery segment personalization }, metadata: { domain_key: "Pacific", // Provided by your Discovery consultant view_id: "en_US", // Provided by your Discovery consultant test_data: true, // Ignores events in Discovery on production debug: true // Enables real-time integration mode in Discovery } }, }); brweb.start(); ``` -------------------------------- ### Configure SDK with Stream Settings Source: https://documentation.bloomreach.com/data-hub/docs/configure-ios-sdk-with-jwt-authentication Initialize the Exponea SDK with StreamSettings to route tracking through Data hub event streams. Ensure you replace 'YOUR_STREAM_ID' with your actual stream ID. The baseUrl defaults to 'https://api.exponea.com' if not provided. ```swift import ExponeaSDK Exponea.shared.configure( Exponea.StreamSettings( streamId: "YOUR_STREAM_ID", baseUrl: "https://api.exponea.com" ), pushNotificationTracking: .disabled ) ``` -------------------------------- ### API Request Example for Cart Update Source: https://documentation.bloomreach.com/data-hub/docs/sdk-tracking-required-events-details This is an example of the API request payload for a cart update event, including customer IDs, event type, properties, and metadata. ```json { "commands": [ { "name": "customers/events", "data": { "customer_ids": { "cookie": "d218dfa8-37eb-4cd1-aec0-421ad6ccc5c9" }, "event_type": "cart_update", "properties": { "action": "add", "title": "Yellow wide sweater with turtleneck", "product_id": "119479", "variant_id": "MJ12199-0400", "product_list": [ { "product_id": "119479", "quantity": 2 } ], "total_price": 99.98, "page_title": "Pacific | Clothing & accessories", "lang": "en-US", "location": "https://www.pacific.com/en/clothing/sweaters-cardigans/turtleneck.html", "referrer": "https://www.pacific.com/", "os": "Windows", "browser": "Chrome", "device": "Other" }, "metadata": { "_br_uid_2": "uid=7080827054609:v=cde-v3.38.0:ts=1741771054202:hc=6", "domain_key": "Pacific", "view_id": "en_US" }, "timestamp": 1749545984.278 } } ] } ``` -------------------------------- ### API Request Example for suggest_click and view_search_results Source: https://documentation.bloomreach.com/data-hub/docs/sdk-tracking-required-events-details This JSON object demonstrates an API request that includes both a 'suggest_click' event and a 'view_search_results' event, with the 'suggest_click' event being deferred. ```json { "commands": [ { "name": "customers/events", "data": { "customer_ids": { "cookie": "d218dfa8-37eb-4cd1-aec0-421ad6ccc5c9" }, "event_type": "suggest_click", "properties": { "q": "turtleneck", "aq": "tur", "catalogs": [ { "name": "products_en", "view_ids": ["en_US"] } ], "page_title": "Pacific | Clothing & accessories", "lang": "en-US", "location": "https://www.pacific.com/", "referrer": "https://www.google.com/", "os": "Windows", "browser": "Chrome", "device": "Other" }, "metadata": { "_br_uid_2": "uid=7080827054609:v=cde-v3.38.0:ts=1741771054202:hc=6", "domain_key": "Pacific", "view_id": "en_US", "debug": true, "test_data": true }, "timestamp": 1749545984.278 } }, { "name": "customers/events", "data": { "customer_ids": { "cookie": "d218dfa8-37eb-4cd1-aec0-421ad6ccc5c9" }, "event_type": "view_search_results", "properties": { "search_term": "turtleneck", "catalogs": [ { "name": "products_en", "view_ids": ["en_US"] } ], "page_title": "Pacific | Clothing & accessories", "lang": "en-US", "location": "https://www.pacific.com/en/catalogsearch/result?q=turtleneck", "referrer": "https://www.pacific.com/", "os": "Windows", "browser": "Chrome", "device": "Other" }, "metadata": { "_br_uid_2": "uid=7080827054609:v=cde-v3.38.0:ts=1741771054202:hc=6", "domain_key": "Pacific", "view_id": "en_US", "debug": true, "test_data": true }, "timestamp": 1749545984.278, "deferred_event": { "type": "suggest_click", "properties": { "q": "turtleneck", "aq": "tur", "catalogs": [ { "name": "products_en", "view_ids": ["en_US"] } ] } } } } ] } ```