Clear History

Track Product Views

Product view events are commonly used to track a user visiting a product page.

Product view


Product view events

In this section, we will showcase how to track product view events.

trackProductView

To track a product view you can use the trackProductView method with the following attributes:

import { trackProductView } from '@snowplow/browser-plugin-snowplow-ecommerce';

trackProductView(product: Product);

Example usage:

import { trackProductView } from "@snowplow/browser-plugin-snowplow-ecommerce";

trackProductView({
    id: "P125",
    name: "Baseball T",
    brand: "Snowplow",
    category: "Mens/Apparel",
    price: 200,
    currency: "USD",
});

trackProductView

To track a product view you can use the trackProductView method with the following attributes:

/* {trackerName} is a placeholder for the initialized tracker on your page.  */

window.snowplow("trackProductView:{trackerName}", product: Product);

Example usage:

window.snowplow("trackProductView:{trackerName}", {
    id: "12345",
    name: "Baseball T",
    brand: "Snowplow",
    category: "apparel",
    price: 200,
    currency: "USD",
});

Where product can have the following attributes:

attributetypedescriptionrequired
idstringSKU or product ID.
currencystringCurrency in which the product is being priced (ISO 4217).
pricenumberPrice of the product at the current time.
namestringName or title of the product.
categorystringCategory the product belongs to. Use a consistent separator to express multiple levels. E.g. Woman/Shoes/Sneakers. The number of levels is defined by the user.
list_pricenumberRecommended or list price of a product.
quantitynumberQuantity of the product taking part in the action. Used for Cart events.
sizestringSize of the product. E.g. XL, XS, M.
variantstringVariant of the product. E.g. Red, Heavy, Leather.
brandstringBrand of the product.
inventory_statusstringInventory status of the product. E.g. in stock, out of stock, preorder, backorder.
positionnumberPosition the product was presented in a list of products. Used in Product List events.
creative_idstringIdentifier/Name/Url for the creative presented on a list or product view.