OneTrace.pro Help center

Recommendation widgets on your website

A widget is a ready-made product block on your website: "You may also like" on the home page, "Bought together" on a product page, "Recently viewed" in the cart. You set it up in OneTrace.pro and paste a short code snippet into your website once. After that, you can change the type, styling, display rules, and on/off status without editing your website.

Widgets require the installed tracker (Connecting your website), a product catalog, and view, cart, and purchase events (Recommendations and product catalog). Owner, Administrator, and Manager can create and edit widgets; other roles can see the settings and statistics but can't save changes.

Widget list

Open Website → Widgets. Each widget card shows its status, statistics for 30 days, a comparison of variants if there are any, and the website code.

Recommendation widgets page: widget list with statistics and website code

The Show on the website switch turns the widget off without editing your website: the status changes to Paused and the block on the page is cleared. Turn it back on and the products return. The trash button deletes the widget completely.

To create a widget, click Create widget. To edit one, click its name or the pencil button. Both open the editor page.

Widget editor

On the left are the settings, in four sections: Products, Look, Display, and Variants. On the right is the preview: it renders the widget just as it appears on your website, using real products from your catalog. If a section has an error, a mark appears next to its name. Click Save and the changes appear on your website the next time the page loads; you don't need to change the code. If you leave the page with unsaved changes, the browser warns you.

Widget editor: the Products section and the preview

The Desktop / Phone switch above the preview shows both layouts. On your website, the layout adapts to the width of its container, not the screen: in a narrow column, the widget looks the same as on a phone. The widget takes its font and text color from your website unless you set your own.

Products

Field What it sets
Name the widget's name; visible only in the admin panel
What to show the recommendation type: Personal, Popular, Trending, Viewed together, Bought together, Similar, Recently viewed, Time to reorder
Category for Popular and Trending: a catalog category ID; empty means the whole catalog
Products in total from 1 to 24
Product for the preview for Viewed together, Bought together, and Similar: the ID of the product the preview is built for; empty means the first product in stock

If there are no matching products, the preview shows gray placeholders so you can check the styling.

Look

Field What it sets
Heading text above the products, for example "You may also like"
Button the button text on the card, for example "Details"; empty means no button
Layout Grid or a scrolling Carousel
Cards per row from 1 to 8
Show price the price on the card
Ready-made styles Like the website, Cards, Minimal, Contrast: they fill in the styling fields, which you can then change
What the card shows brand, old price, discount badge, card border and shadow
Image proportions and Image 1:1, 3:4, or 4:3; the whole image, or filling the space with the edges cropped
Colors accent, card background, image background, text, price, button, and button text; without a color, the website's own is used, and the image background is white
Text size, Heading size, Heading sizes as a percentage of the website's font, and heading alignment
Corner radius, Gap between cards, Card padding in pixels
Carousel arrows scroll buttons at the edges of the carousel
Phone cards per row on a narrow screen (from 1 to 3) and a separate layout, for example a carousel instead of a grid
Custom CSS rules for the widget's classes: .cdp-rec__name, .cdp-rec__price, .cdp-rec__button, and others

Custom CSS applies only inside this widget and doesn't affect the rest of the page. It can't load external resources: @import, url(), and similar constructs are rejected when you save.

If the project has several languages, a Text language switch appears above the heading. In the default language you fill in the Heading and the Button, in the other languages their translations; an empty field shows the default-language text. Visitors see the heading and the button in their own language, the one the tracker sends to the profile (Customer language); without a translation, in the default language. Prices are formatted for the visitor's language.

Style from an image

The Style from an image button in the Look section picks the styling from a screenshot with product cards, taken from your website or from one you like.

  1. Click Style from an image.
  2. Drag in an image, paste it from the clipboard (Ctrl+V), or choose a file: PNG, JPEG, or WebP up to 3 MB.
  3. If the widget has variants, choose which one to apply the style to.
  4. Click Match the style.

AI fills in the colors, sizes, corner radius, layout, and what the card shows, and adds anything the settings can't express to Custom CSS. Each value is checked the same way as manual input, and unsuitable ones are discarded. The result is a draft: check the preview and save, or click Undo.

Style from a screenshot

The image isn't stored. Matching is paid from the project balance based on actual usage; if the balance is too low or AI isn't included in your plan, the button is unavailable and the reason is shown below it.

Display

The Display section: rules, on/off switch, and website code

Field What it sets
Show on the website turns the widget on or off, same as in the list
Only on pages and Except pages page addresses without the domain, one per line; * matches any characters, for example /catalog/*. Empty means all pages
Devices all, desktops only, or phones only
Visitors all, new only, or returning only
Only to members of segments and Except members of segments the visitor's segments; membership is checked against the profile on every display

The server checks the rules every time the widget loads. Outside the rules, the space on the page stays empty and the layout doesn't break. The rules are the same as for subscription forms.

This section also has the Website code, described below.

Variants

Variants let you test which heading, recommendation type, or styling brings more clicks and purchases. The widget's main settings are variant A. Click Add variant to add up to three variants: B, C, and D. In each one you can change:

  • the recommendation type (What to show);
  • the Heading and the Button, with translations;
  • the layout and all styling.

Empty fields are taken from variant A.

The Variants section: variant B with a different heading and styling

Visitors are split evenly between variants, and each visitor always sees the same variant. The switch above the preview shows the selected variant. Comparison results are in the statistics below the editor.

View on your website

The View on your website button above the preview opens a page of your website with the widget as saved. Enter the address of a page that has the widget code, choose a variant, and click Open.

This way the widget is visible even if it's turned off or the page doesn't match the display rules. Impressions and clicks in this mode aren't counted in the statistics. The link is valid for 24 hours; while the tab is open, preview mode stays on as you navigate your website. Unsaved changes aren't visible on the website, so save first.

Website code

The widget code is on its card in the list and in the Display section of the editor. Paste it into the page template where the block should appear:

<div data-cdp-widget="a1b2c3d4e5f6" data-item="SKU-1"></div>

Attributes:

  • data-item: the product ID of the page, or comma-separated IDs of cart products: data-item="SKU-1,SKU-7". Required for the Viewed together, Bought together, and Similar types; fill it in from the page template.
  • data-category: a category ID for popular products, if different pages need different categories.
  • data-exclude: comma-separated IDs of products that shouldn't be shown, for example ones already in the cart.

Personal and recently viewed products are picked for the visitor, so they don't need data-item.

If there are no matching products, the space on the page stays empty and the layout doesn't break.

Statistics

Below the editor are the widget's statistics for 7, 30, or 90 days: totals, a daily chart, and a comparison of variants. Above the chart, choose the metric: impressions, clicks, CTR, or revenue. If the widget has variants, each one has its own line on the chart.

Widget statistics: totals, daily chart, and variant comparison

Metric How it's calculated
Impressions at least half of the widget came into the visitor's view. A page load without scrolling to the block doesn't count, so the CTR of a widget at the bottom of the page is accurate
Clicks clicks on product cards
CTR clicks divided by impressions
Purchases purchases of the product by the same customer within 7 days of clicking it; on the chart, counted on the day of the first click
Revenue the total of those purchases

Days are counted in UTC. Impressions and clicks from viewing on your website aren't counted.

The variant table shows impressions, clicks, CTR, purchases, and revenue for each variant. Below it is a verdict on clicks and on purchases per impression: which variant is better and whether there is already enough data to rely on it. While there's little data, the verdict says so: wait rather than pick a variant based on a random difference.

The overall effect of recommendations on your website by type is in the Recommendations section.

Single-page websites

The tracker finds widgets on its own after the page loads, when new elements appear, and when data-item changes. So on websites built with React, Vue, and similar frameworks, changing the attribute is enough: the block re-renders.

If you need to refresh the products without changing attributes, for example after the cart changes, call:

cdp.widgets({ force: true });

Your own code instead of a widget

Developers can render a recommendation block from code, without setting it up in the admin panel:

window.addEventListener('load', () => {
  cdp.renderRecommendations('#recs', {
    type: 'viewed_with', item: 'SKU-1', title: 'Viewed together', layout: 'carousel', columns: 4,
  });
});

The block looks the same as a widget, and impressions and clicks are counted automatically. You can call it before the tracker loads: the call waits in the queue. The element must already be on the page, which is why the example waits for the load event. An empty result clears the element. Styling uses the same options as widgets from the admin panel, for example imageRatio: '4:3', imageFit: 'cover', imageBackground: 'transparent', background: '#111827', textColor: '#f9fafb'; imageBackground is a color or transparent. Display rules and variants are available only for widgets set up in the admin panel.