Learn all about using product recommendations on your site.
You can show product recommendations on your website by embedding our scripts. Depending on your knowledge, you may need a developer to help you with this.
How onsite recommendations work
The script on your page needs to include the ID of the recommendation to insert. This is included in the embedding scripts.
Types of onsite recommendation
These non-predictive recommendations have embedding options for your website:
- Best sellers
- Most viewed
- Custom category
- Also bought
Each of these recommendations is suitable for your homepage or category hub pages.
Example uses of Onsite recommendations
Best selling women's products
Popular products under $50
For a hub page with female-focused products:
Best selling women's snowboards
Trending women's accessories
Women's snowboots under $50
Product page (using also bought):
Customers who bought this also bought
View and edit the embedding code
The embedding code provided by us is complete. For developers who wish to simplify it, the notes provided below will be helpful.
To find your embedding code:
- Go to Ecommerce > Product recommendations.
- Find the Product recommendation you want to embed, then select Onsite.
- The embedding code opens in Edit website template side panel.
Using the embedding code
To access the scripts, select Get template scripts. You'll then be able to set the number of products to show and copy/paste the script onto your website.
new dd.ProductRecommendations.SnippetCreator('dd-product-recommendations-container', 'https://dmtrk.net', '4P8Z', '4K', 3).createSnippets();
The targeted HTML element (by ID) is the first variable. In the above example, it's set to the default HTML element provided by our templates: dd-product-recommendations-container.
The platform's site is then set (and shouldn't be changed): https://dmtrk.net.
The following variables - '4P8Z', '4K' - identify the account and then the recommendation to be embedded. The recommendation ID could be set dynamically by your website.
The final variable sets the number of products to show, in this case 3.
Customise the template
The Edit website template side panel contains two areas:
- Edit website template, where you design and style your recommendation block
- Template scripts, where you grab the code for your website
To learn how to get to the Edit website template side panel, check out the section View and edit the embedding code.
You can insert product fields anywhere in your product block template. To add a product field:
- Go to the Edit website template side panel.
To learn more, check out the section View and edit the embedding code.
- Select INSERT PRODUCT FIELD.
- Select the field you want to add.
Performance and caching
In order to ensure high performance, onsite product recommendations make use of our caching. This should ensure that your site is never slowed down by recommendations loading. It may, however, mean that rapid changes to your recommendation logic or template are not seen immediately.