displaying top 4 products in home page using adobe target | Community
Skip to main content
sriharshanaladala98
Level 2
October 23, 2024
Solved

displaying top 4 products in home page using adobe target

  • October 23, 2024
  • 1 reply
  • 2263 views

@kandersen

hi i want to create a recommendation on home based which are top 4 viewed products using adobe target,
where i already created products feed and also collection based on those 43 products

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kandersen-1

thank you bro for the help finally, i got the recommendations, 


Good stuff. Glad to hear you got it working!

Appreciate if you can mark the thread Resolved by choosing a correct reply. This helps others with similar problems to quickly find the answer.

1 reply

kandersen-1
Community Advisor
Community Advisor
October 23, 2024

More background on the question here: https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/adobe-target-recommendation-activity-the-most-viewed-products/m-p/712791/highlight/true#M11610 

Target is displaying recommendation based on visitors behaviour. So creating a product feed and creating the activity is a great start, next step is to ensure that Target is informed every time a product is viewed and puchased. In order for Target to receive these information you need to be passing entity parameters on every product view. Read more about it here: https://experienceleague.adobe.com/en/docs/target/using/recommendations/entities/entity-attributes

The minimum entity to set is entity.id - it is important that this id is the same as the id used in your product feeds. You then use your product feeds to add meta data to the product id. 

Once the entity.id is set on every product page, Target will start collecting how many times a product is viewed. This is required in order for Target to create the most viewed criterias.

I hope this helps!

Test forum signature
sriharshanaladala98
Level 2
October 23, 2024

async function fetchAndSendProducts() {
try {
const response = await fetch('med_products.json'); // Await the fetch call
const products = await response.json(); // Await the JSON parsing

// Create a string for the product ids and other attributes
const productIds = products.map(product => product.id).join(",");
const productNames = products.map(product => product.name).join(",");
const productCategoryIds = products.map(product => product.categoryId).join(",");
const productManufacturers = products.map(product => product.manufacturer).join(",");

// Set the target page parameters
const targetPageParams = {
"entity.id": productIds,
"entity.name": productNames,
"entity.categoryId": productCategoryIds,
"entity.manufacturer": productManufacturers
};

// Ensure products are available before sending to Adobe Target
adobe.target.getOffer({
"mbox": "target-global-mbox", // Your mbox name
"params": targetPageParams, // Pass the page parameters here
"success": function(offer) {
// Handle the offer (e.g., apply content changes to the page)
console.log("Offer successfully received:", offer);
adobe.target.applyOffer({
"mbox": "target-global-mbox", // Ensure the same mbox name
"offer": offer // Apply the received offer
});
},
"error": function(error) {
// Handle any error while getting the offer
console.error("Error in getting offer:", error);
}
});
} catch (error) {
console.error('Error fetching products or sending to Adobe Target:', error);
}
}

// Call the function when needed, such as on page load
fetchAndSendProducts();
...................................................................
ca i do like this i even attached the pageload parameters i getting after this

sriharshanaladala98
Level 2
October 24, 2024

The URLs were just example URLs, not real ones to give you an idea. You can see a real example here.


thank you bro for the help finally, i got the recommendations,