Add to cart

The following describes how add to cart tracking is done for Firework.

How to implement the "add_to_cart" tracking event

<script>
    function onAddToCart() {
        window._fwn.analytics.addToCart({
            ext_customer_identifier: '123'
            currency: 'CAD',
            country: 'Canada',
            subtotal: '31.89',
            product: [{ 
                ext_parent_product_id: '6692',
                parent_product_name: 'V-Neck Tshirt',
                ext_product_id: '4483', 
                product_name: 'V Neck Tshirt - L Blue', 
                image: 'http://example.com/t-shirt/t-shirt.png'
                price: 31,
                currency: 'CAD',
                sku: 't-shirt',
                quantity: 1                
            }]
        });
    }
    
    // Calls onAddToCart() whenever there is add to cart happening
</script>

Note: The add to cart function expects the following input shape:

export interface AddToCartData {
  ext_customer_identifier?: string
  currency: string
  country: string
  subtotal: number
  product: Array<{ 
    ext_parent_product_id:string; 
    parent_product_name:string;  
    ext_product_id:string; 
    product_name:string; 
    image?: string;
    price: number; 
    currency?: string;
    sku?: string;
    quantity: number 
  }>
}

Last updated