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
| Parameter | Type | Required | Description |
|---|---|---|---|
eventType | String | Yes | Must be set to 'sale' for revenue tracking. |
eventName | String | Yes | A unique identifier for the transaction, such as the Order ID (e.g., "Order #1001"). |
eventValue | Number | No | The total revenue amount (e.g., 50.00). Do not include currency symbols. |
metadata | Object | No | Additional context like currency, coupon codes, or item lists. |