Expand my Community achievements bar.

SOLVED

displaying top 4 products in home page using adobe target

Avatar

Level 2

@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

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

12 Replies

Avatar

Community Advisor

More background on the question here: https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/adobe-target-recommendation-... 

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!

Avatar

Level 2

i have 43 products do i need to pass all the products id to entity 

 

Avatar

Community Advisor

In production, yes.

 

In development for testing, no.

For example, if your design is only developed to show 6 product recommendations, there is no point in collecting data from all 43 products from a testing perspective. However, in production you would like to ensure that the most viewed products are shown. In order for Target to know which product(s) are the most viewed you need to be collecting data for all of them.

 

When it comes to recommendation you can think of Target like Analytics. In order for the Criterias to know what to show it needs data - this data is collected through the entity parameters when visitors view and purchase products.

You can set multiple entity parameters. This is primarily for the purpose of using this meta data in the Criterias or in your design - e.g. you can pass in whether a product is in stock or not and then configure you criteria to not promote products if they are not in stock.

For some it is easier to add this meta data through a feed. In those scenarios you would only implement the entity.id and this value then functions as a key for when you upload all the data about the product via the feed.

The feed on the other hand has nothing to do with providing data into which product is the most viewed - this is purely done through the entity.id parameter.

Avatar

Level 2

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

Avatar

Community Advisor

Based on your screendump it seems you're populating all the product values in 1 request. You need to only pass the information that is relevant to the product that is being viewed. 

 

Avatar

Level 2

id is enough right in that case do i need to pass id of the all products in case iam on production

 

Avatar

Community Advisor

Yes, entity.id is all you need. And you'll have to pass it on every product detail page. Like this:

http://domain.com/products/headphones/bose1234
Entity.id: bose1234

http://domain.com/products/headphones/sony1345
Entity.id: sony1345

Avatar

Level 2

iam unable to open the url can you i want to display recommendations on home page so then where i need to pass the id from home page

 

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

Correct answer by
Community Advisor

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.