--- title: "trackCategoryView()" slug: "trackcategoryview" updated: 2024-07-26T14:47:17Z published: 2024-07-26T14:47:17Z canonical: "docs.xgen.ai/trackcategoryview" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.xgen.ai/llms.txt > Use this file to discover all available pages before exploring further. # trackCategoryView() `trackCategoryView()` is used to track when a user views a category which is typically done on a Product Listing Page (PLP). This is primarily used to enhance XGen’s prediction performance. #### Syntax ```javascript trackCategoryView(category); ``` #### Parameters `category` **type:** `string` **description:** The category or PLP page that the user is currently viewing. This should match a value in either `product_types` or `product_categories` within the XGen catalog. #### Return Value This function has no return value. #### Examples ##### Tracking a category view event In this example we are grabbing the category from the URL and passing it into the `trackCategoryView()` function. ```javascript // Import the integration from the 'installation' step import { integration } from './xgenSdkIntegration'; // Extracting the category from the URL using regex (grabs the last item in the path) const category = /\/(?[^/]+)\/?$/.exec(location.pathname)?.groups?.category; // Send the category view event integration.trackCategoryView(category); ```