Documentation

Sales Tracking Setup

Learn how to manually track purchases and revenue using the LinkWrangler snippet.

Overview

While LinkWrangler automatically tracks page views and button clicks, sales (conversions) often happen dynamically after a checkout process. To track these events, you can use the exposed window.LinkWrangler.trackEvent function.

Implementation Guide

Add the following code to your "Thank You" or "Order Confirmation" page. Ensure this script runs after the main LinkWrangler snippet has loaded.

1. Standard Purchase Event

<script>
  // Wait for LinkWrangler to load
  window.addEventListener('load', function() {
    if (window.LinkWrangler && window.LinkWrangler.trackEvent) {
      
      window.LinkWrangler.trackEvent(
        'sale',               // Event Type (Required)
        'Order #12345',       // Event Name / Order ID
        99.99,                // Event Value / Revenue (Number)
        {                     // Metadata (Optional)
           currency: 'USD',
           items: ['Product A', 'Product B']
        }
      );
      
    }
  });
</script>

2. Using with Stripe / Payment Gateways

If you are using a third-party payment gateway, you may need to inject this script on the redirect page returned by the proccessor.

Parameters

ParameterTypeRequiredDescription
eventTypeStringYesMust be set to 'sale' for revenue tracking.
eventNameStringYesA unique identifier for the transaction, such as the Order ID (e.g., "Order #1001").
eventValueNumberNoThe total revenue amount (e.g., 50.00). Do not include currency symbols.
metadataObjectNoAdditional context like currency, coupon codes, or item lists.