Method Signature
Parameters
Parameters for the purchase event
Optional parameters for the network request
Returns
Returnstrue on success, false if the order was already tracked, or an Error object if validation fails.
Examples
Basic Example
Complete Example
Example with Analytics Tags
Integration Example
E-commerce Platform Example
When to Use
CalltrackPurchase() when:
- A user completes checkout and reaches the order confirmation page
- An order is successfully processed
- Payment is confirmed
Important Notes
Revenue Calculation
revenueshould be the order subtotal (sum of item prices)- Exclude taxes, shipping costs, and fees
- Use the actual purchase price, not the original/MSRP price
Item Limits
- The
itemsarray can contain up to 100 items - Items beyond 100 are automatically truncated
Duplicate Prevention
The SDK automatically prevents duplicate purchase tracking:Item Object Format
Each item in theitems array should have:
Order ID Best Practices
- Always include an
orderIdto prevent duplicate tracking - Use your system’s unique order identifier
- Ensure the ID is consistent across your systems
- The SDK stores tracked order IDs in browser storage
Relationship with Conversions
Track both conversions and purchases:- trackConversion - When item is added to cart
- trackPurchase - When order is completed (this method)
API Endpoint
This method sends aPOST request to:
Related Methods
- trackConversion - Track add-to-cart events
- trackSearchResultClick - Track search result clicks
- trackBrowseResultClick - Track browse result clicks
- trackRecommendationResultClick - Track recommendation clicks