Composables

useBazaarvoice

Description

The useBazaarvoice composable integrates Bazaarvoice's tracking functionality into a Nuxt application. It provides methods to track various user interactions, including purchases, page views, and custom events. The composable formats the order data to match Bazaarvoice's requirements, and it allows you to send relevant event data such as customer information, order details, and product specifics to Bazaarvoice for review and feedback tracking.

FEATURE GOALS

  • Track purchase events with detailed order and customer information.
  • Track page views to monitor user navigation and engagement.
  • Track custom events for flexible event tracking beyond predefined actions.
  • Format order data for Bazaarvoice transactions, ensuring the correct structure for event tracking.

FEATURE EXPECTATIONS

  • Provides methods to track purchases, page views, and custom events.
  • Automatically formats order data for purchases to comply with Bazaarvoice's required structure.
  • Allows tracking of custom events by passing an event name and additional data.
  • Simplifies the integration with Bazaarvoice for both page and event tracking.

DEV STRATEGIES

  1. Composables Logic
const { trackPurchase, trackPage, trackCustomEvent } = useBazaarvoice();

// Example of tracking a purchase
trackPurchase(orderStore);

// Example of tracking a page view
trackPage();

// Example of tracking a custom event
trackCustomEvent("product_view", { productId: "12345", category: "electronics" });
  • The composable offers three primary functions:
    • trackPurchase sends transaction data to Bazaarvoice.
    • trackPage tracks page views.
    • trackCustomEvent tracks custom events based on provided event name and data.
  1. COMPOSABLE STRUCTURE
useBazaarvoice(): {
  trackPurchase: (orderStore: OrderStore) => void;
  trackPage: () => void;
  trackCustomEvent: (eventName: string, data?: object) => void;
}
  1. DEFAULT BEHAVIOR
OptionDefaultDescription
currencyEURDefault currency used for tracking transactions
orderIdorderStore.order_idUnique identifier for the order.
totalorderStore.order.data.order_totals.raw.toString()Total order value.
itemsProduct data in orderStoreList of products in the order, formatted with details like product ID, price, and quantity.
customerCountryNLDefault customer country for tracking (can be adjusted).
trackPagetrueTracks page views by default when the method is called.

  1. ERROR RESPONSE STRUCTURE
  • The composable does not have explicit error handling, but any issues in tracking will generally result in silent failures in the Bazaarvoice SDK's internal implementation.

FLOW SUMMARY

  • The composable provides three key methods:
    • trackPurchase: Tracks completed purchase transactions with detailed product and customer information.
    • trackPage: Tracks page views, helping to measure user engagement and site traffic.
  • trackCustomEvent: Allows for flexible custom event tracking by passing the event name and optional data.
  • The trackPurchase method automatically formats the order data from the orderStore to match Bazaarvoice’s requirements before sending it.
  • The composable integrates smoothly with the Bazaarvoice SDK, making it easy to track key e-commerce events.

Copyright © 2026