--- title: "setPdpProduct()" slug: "setpdpproduct" updated: 2024-06-13T14:12:06Z published: 2024-06-13T14:12:06Z canonical: "docs.xgen.ai/setpdpproduct" --- > ## 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. # setPdpProduct() `setPdpProduct()` is used to tell the prediction API what product page is currently being viewed. This information is used for recommendation types such as co-viewed, co-purchased, and recently viewed. The prediction API will also exclude this product from recommendations automatically. > PDP product must be set prior to the prediction API being called. Otherwise, the PDP product will not be included in the request. #### Syntax ```javascript setPdpProduct(prodCode) ``` #### Parameters `prodCode` **type:** `string` **description:** The product code of the product page that the user is currently viewing. Note: the product code has to match exactly 1 to 1 what is mapped in XGen’s catalog. Otherwise this functionality will not work. #### Return Value This function has no return value. #### Examples ##### Set the PDP product In this example, we will get the product ID from the window object and set that ID as the current PDP product. ```javascript // Create integration (use existing integration if you already created one) const integration = new XG(...config); // Get the product code const pdpProductId = window.product.id // Set the pdp product integration.setPdpProduct(pdpProductId); ```