Skip to content

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.

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.

  • data-fusionaly-metadata-price: Price in cents (e.g., 1999 for $19.99)
  • data-fusionaly-metadata-currency: Currency code (e.g., USD, EUR)
  • data-fusionaly-metadata-quantity: Number of items (defaults to 1)
  • data-fusionaly-metadata-product: Product identifier or name
  • data-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>

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.

Track a simple purchase with just the price and currency:

// Track a $19.99 purchase
window.Fusionaly.registerPurchase(1999, "USD");

This creates a revenue:purchased event with price: 1999, currency: ‘USD’, and quantity: 1 (default).

Include additional product and purchase information for detailed revenue analytics:

// Track a purchase with additional metadata
window.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 identifier
  • productName: Human-readable product name
  • category: Product category or type
  • quantity: Number of items purchased (defaults to 1)
  • discountCode: Applied discount or promo code
  • paymentMethod: Payment method used

Common integration patterns for different scenarios:

// After successful payment processing
Fusionaly.registerPurchase(2999, "USD", {
productId: "widget-pro-123",
productName: "Widget Pro",
category: "software",
quantity: 1,
discountCode: "SAVE20",
paymentMethod: "stripe",
});
// Monthly subscription signup
Fusionaly.registerPurchase(999, "USD", {
productId: "plan-monthly",
productName: "Monthly Plan",
category: "subscription",
billingCycle: "monthly",
planType: "premium",
});
// Digital product purchase
Fusionaly.registerPurchase(1999, "USD", {
productId: "ebook-advanced-js",
productName: "Advanced JavaScript Guide",
category: "digital-content",
format: "pdf",
fileSize: "2.5MB",
});