Revenue Tracking
Track purchases and revenue with Fusionaly
Track revenue events and purchases with Fusionaly’ built-in purchase tracking functionality. This provides standardized revenue analytics and integrates seamlessly with your existing analytics data.
Fusionaly offers two approaches for purchase tracking: programmatic tracking using the registerPurchase() function, and automated tracking using HTML attributes. Both methods create the same standardized revenue:purchased events.
Automated Purchase Tracking
Section titled “Automated Purchase Tracking”Track purchases automatically using HTML attributes by setting data-fusionaly-event-name="revenue:purchased" on buttons or links. This approach is ideal for checkout flows, payment buttons, purchase links, or any purchase-related actions that can be tracked declaratively.
Required metadata attributes:
Section titled “Required metadata attributes:”data-fusionaly-metadata-price: Price in cents (e.g., 1999 for $19.99)data-fusionaly-metadata-currency: Currency code (e.g., USD, EUR)
Optional metadata attributes:
Section titled “Optional metadata attributes:”data-fusionaly-metadata-quantity: Number of items (defaults to 1)data-fusionaly-metadata-product: Product identifier or namedata-fusionaly-metadata-category: Product category
<!-- Button example --><button data-fusionaly-event-name="revenue:purchased" data-fusionaly-metadata-price="2999" data-fusionaly-metadata-currency="USD" data-fusionaly-metadata-product="premium_plan" data-fusionaly-metadata-quantity="1" data-fusionaly-metadata-category="subscription"> Purchase Premium Plan</button>
<!-- Link example --><a href="/checkout/complete/" data-fusionaly-event-name="revenue:purchased" data-fusionaly-metadata-price="4999" data-fusionaly-metadata-currency="USD" data-fusionaly-metadata-product="yearly_subscription" data-fusionaly-metadata-quantity="1"> Complete Purchase</a>registerPurchase Function
Section titled “registerPurchase Function”The registerPurchase function automatically creates a revenue:purchased custom event with standardized purchase data. This ensures consistent revenue tracking across your entire application.
Syntax: Fusionaly.registerPurchase(priceInCents, currency, metadata)
- priceInCents (number, required): The purchase price in cents (e.g., 1999 for $19.99). Must be a positive number.
- currency (string, optional): Currency code following ISO 4217 standard (defaults to ‘USD’).
- metadata (object, optional): Additional purchase information like product details, quantity, categories, etc.
Basic Usage
Section titled “Basic Usage”Track a simple purchase with just the price and currency:
// Track a $19.99 purchasewindow.Fusionaly.registerPurchase(1999, "USD");This creates a revenue:purchased event with price: 1999, currency: ‘USD’, and quantity: 1 (default).
Advanced Usage with Metadata
Section titled “Advanced Usage with Metadata”Include additional product and purchase information for detailed revenue analytics:
// Track a purchase with additional metadatawindow.Fusionaly.registerPurchase(1999, "USD", { productId: "prod_123", productName: "Premium Plan", quantity: 1, category: "subscription",});The metadata object can include any additional fields relevant to your business such as:
productId: Unique product identifierproductName: Human-readable product namecategory: Product category or typequantity: Number of items purchased (defaults to 1)discountCode: Applied discount or promo codepaymentMethod: Payment method used
Integration Examples
Section titled “Integration Examples”Common integration patterns for different scenarios:
E-commerce Checkout
Section titled “E-commerce Checkout”// After successful payment processingFusionaly.registerPurchase(2999, "USD", { productId: "widget-pro-123", productName: "Widget Pro", category: "software", quantity: 1, discountCode: "SAVE20", paymentMethod: "stripe",});Subscription Purchase
Section titled “Subscription Purchase”// Monthly subscription signupFusionaly.registerPurchase(999, "USD", { productId: "plan-monthly", productName: "Monthly Plan", category: "subscription", billingCycle: "monthly", planType: "premium",});Digital Download
Section titled “Digital Download”// Digital product purchaseFusionaly.registerPurchase(1999, "USD", { productId: "ebook-advanced-js", productName: "Advanced JavaScript Guide", category: "digital-content", format: "pdf", fileSize: "2.5MB",});