view_cart Event

The view_cart event captures when a user views the shopping cart page. This is a key step in the ecommerce funnel and helps identify drop-offs before checkout.

The view_cart model

This model describes the items in the cart at the time of viewing.

Properties

  • Name
    event
    Type
    string
    Description

    Must be set to view_cart.

  • Name
    user_id
    Type
    string
    Description

    Unique identifier for the user.

  • Name
    session_id
    Type
    string
    Description

    Current session ID.

  • Name
    ecommerce.currency
    Type
    string
    Description

    ISO 4217 currency code (e.g., USD).

  • Name
    ecommerce.value
    Type
    float
    Description

    Total value of the items in the cart.

  • Name
    ecommerce.items
    Type
    array
    Description

    Array of items currently in the cart.

  • Name
    ecommerce.items[].item_id
    Type
    string
    Description

    SKU or product ID.

  • Name
    ecommerce.items[].item_name
    Type
    string
    Description

    Name of the product.

  • Name
    ecommerce.items[].item_brand
    Type
    string
    Description

    Product brand.

  • Name
    ecommerce.items[].item_category
    Type
    string
    Description

    Product category.

  • Name
    ecommerce.items[].item_variant
    Type
    string
    Description

    Variant such as size or color.

  • Name
    ecommerce.items[].price
    Type
    float
    Description

    Price per unit.

  • Name
    ecommerce.items[].quantity
    Type
    int
    Description

    Quantity of the item in the cart.


Push event to the dataLayer

dataLayer.push example

dataLayer.push({
  event: 'view_cart',
  user_id: 'user-1234',
  session_id: 'session-5678',
  ecommerce: {
    currency: 'USD',
    value: 129.98,
    items: [
      {
        item_id: 'SKU-1001',
        item_name: 'Noise Cancelling Headphones',
        item_brand: 'QuietTech',
        item_category: 'Electronics',
        item_variant: 'Black',
        price: 129.98,
        quantity: 1
      }
    ]
  }
});

Best Practices

  • Fire this event once when the cart page loads.
  • Keep your item metadata consistent with add_to_cart and purchase events.
  • Use this for funnel analysis and drop-off retargeting.

Use Cases

The view_cart event supports:

  • Checkout funnel tracking
  • Cart abandonment campaigns
  • Basket value insights
  • On-site behavior segmentation

Was this page helpful?