Use Cases
To get you started and so you can take advantage of all that our platform offers as quickly as possible, we've put together six starter use cases for you. These will provide insight into the workings of the Recommendations and Search capabilities from the XO platform, and get you to use and familiarise yourself with our key features.
The six use cases are:
Recommendations
- Most popular items on the home page.
- Similar product recommendations on product detail pages.
- Complementary product recommendations on basket pages.
- UI / developer-based widget templates.
Search / PLPs
- Custom sort options.
- Custom facet configurations.
1. Most popular items on Home Page
In this example, the widget will display best-selling products, which are generally used on the homepage to encourage product discovery. This means the recommendation will have no product or category restrictions, so it can easily be created using an algorithm.
- Once you've created a widget, navigate to the Merchandising section and select Algorithms.
- Apply the algorithm 'Most popular items' to return the appropriate products.
- You can also specify the number of products you would like to display, shown in the second example.
2. Similar product recommendations on Product Detail Pages
In this example, you will create a widget that displays similar (same category and type) products to the item that is being viewed. First, define the variables so that you can specify the product you're referring to and the appropriate returning products.
The variables that we need to create include the following:
| Variables | Category | Type | What is does |
| $productId | Context | String | This will allow you to reference the current product ID. |
| Variable | Category | Source | Attribute | Variable Type | What it does |
| $product_type | Item | $productId | Type | String | Retrieves the type of product that the user is viewing. For example, if the user is viewing a t-shirt, this will ensure that t-shirts are recommended. |
| $product_category | Item | $productId | Category | String | Returns products in the same category to the product that your users are viewing. For example, viewing a men's t-shirt will ensure the recommendations are also "men's" products. |
Please note that your variable names and attributes may differ from this example and should be created according to your data structure.
The next step is to create the widget within the XO console. To do this, navigate to the Merchandising section and select 'Add a widget'. Populate the general information with the appropriate information and select the Merchandising tab to configure what the widget will display.
The first section lets you specify how many products you want to return in the widget. In the example below, four similar products will be returned to the shopper:
Next, within the 'Required tags (AND)' field, specify the variables you've defined earlier to ensure similar and relevant products are returned to your visitors. Using the variables above, this will be $product_type and $product_category within this section, as shown below.
Once you've put in place the appropriate filtering requirements, you can apply an algorithm to your widget that will provide relevant recommendations. You'll apply the 'Most trendy items of the moment' algorithm. This shows the most popular products that meet the requirements, as defined in the filter section.
3. Complementary products on Basket Pages
In this example, you'll create a widget that will show complementary products to the items in the basket for additional upsell opportunities. To upsell effectively, you should limit the price of the recommended products to below the total value of your cart. This will increase the likelihood of an impromptu discretionary purchase. First, you need to create a variable to reference the total amount in the cart; an example of this is described below.
|
Variable |
Category | Variable Type | What it does |
| $basketAmount | Context | Float | Refers to the total cart amount so that you're able to recommend products lower than the basket value. |
Next, create the widget to display products that are below the cart amount. Populate the general information tab, and then navigate the Merchandising tab. You can specify the maximum value for the products you want to display as $cart_amount to ensure we don't recommend products that exceed the cart value. You can also apply required tags to the widget to ensure the products are within the price range and still relevant, as shown in the image below:
4. Custom widget templates
Custom Widget Templates allow users to create a different look and feel for their widgets from XO. There are two approaches to setting up a widget template, either through the 'Developer approach' or the 'UI approach'. To create a custom widget template from the Attraqt app, you'll need to toggle if it's a developer template and provide the template name and template data/code.
4.1 UI approach
A UI-managed widget template is defined exclusively in the Attraqt app. This is perfect for users familiar with HTML who want the flexibility to configure and deploy widget templates without needing to go through the BigCommerce theme.
To implement this type of widget template, the Developer Template toggle should be off, and the user will be presented with a Template Name and a Template Data field.
The Template Name is used within Page Builder, allowing users to identify a template. The Template Data field contains the HTML that is used to render the recommendations.
The template data field supports a simple templating language called EJS. This allows for the implementation of conditional logic and looping of recommendations results. The API response from the recommendations API is available in the data.recommendations variable.
An example recommendations template follows:
<ul><%= data.recommendations.forEach(function (rec) { %>
<li><h3><%= rec.product.title %></h3>
<img src="<%= rec.product.photo %>"/>
</li><% }) %></ul>
4.2 Developer approach
A developer-managed widget template is defined as a widget template in the Attraqt app, but the HTML should be provided within the BC theme. This is a good approach for developers or agencies that require more flexibility when implementing their templates (such as needing JavaScript to fire before or after a widget is rendered), having requirements around version control, or release processes.
When using a Developer Template, the developer is responsible for implementing the widget template (such as HTML or corresponding JavaScript initialisation) within the BC theme - the Attraqt app cannot be used to manage the widget template's HTML.
The example code below is contained within the BC theme files. In our example, it was added to Template → Components → 'company name' → Custom-Widgets.html.
<scripttype="text/template"
data-attraqt-template
data-attraqt-template-code="example-custom-template"
>
<div>
<h5>Recommendations Debug</h5>
<pre><%- JSON.stringify(data) %></pre>
</div>
</script>
When selecting Developer Template, the user is presented with the Template Name, which is used in Page Builder to identify the widget template, but instead of Template Data, they are presented with the Template Code field. This is a string used to identify the widget template in their code called widgetTemplateId in the callback signatures that follow.
As part of the JavaScript bundle that is injected onto the page from the Attraqt app, there are a number of extension points, in the form of callbacks on window.xobc, that can be implemented. The primary callback is window.xobc.delegateFetchWidgetTemplate(widgetTemplateId: string) which is expected to return a string. If implemented, this callback is expected to return an EJS template for a given widget template.
The other two callbacks are functions that are triggered before and after a widget is rendered to the page. This can be used to implement any JavaScript required to render a richer experience, such as implementing a carousel, additional tracking logic, etc.
- window.xobc.delegateWidgetTemplateRenderBefore(widgetTemplateId: string, isDeveloperTemplate: boolean, widgetInstanceId: string, template: string): string
-
Allows the developer to do two things: trigger some kind of functionality before a widget is rendered (such as informing some other functionality on the site) or modify the template by returning a new template.
-
-
window.xobc.delegateWidgetTemplateRenderAfter (widgetTemplateId: string, isDeveloperTemplate: boolean, widgetInstanceId: string, element: HTMLElement): unknown
-
Allows the developer to trigger some functionality once the widget has been rendered onto the page as an element, such as initialising a carousel, etc.
-
An example developer template is shown below:
5. Custom sort options
PLPs powered by XO Search
The following use cases will require the client to customise their theme to take advantage of having their PLP driven by XO Search. This comes in the form of a custom template and a react library that wraps the whole XO Search API. If you'd like to receive a custom template, please contact your Technical Consultant who can provide assistance.
To create a custom sort option, you'll need to confirm the 'label' name, 'attribute', and 'direction' of sorting.
When choosing a label, it will be presented to customers on the frontend BigCommerce store. It's recommended to keep the label unique, identifiable, and easy to read.
The attribute you select from the dropdown list should be synced with the attributes created on XO. To verify this, you can navigate to the sortable attribute configuration page on XO.
To view this page, navigate to Search → Configuration List → Configuration → Sortable attributes (Relevancy). If further information is required about configuring sortable attributes in XO, please click here.
Selecting the direction will alter the products' order on your product listing page. For example, if you create a sort option with the attribute brand and set the direction to ascending, you can expect to see brands organised on your PLP by brand name in alphabetical order.
Once you've created your sort option, it will reflect seamlessly on the frontend store. Custom sort options that appear on the frontend can be removed, updated, and reorganised via the Attraqt app.
6. Custom facet configurations
To create a custom facet from the Attraqt app, you'll need to provide the 'Attribute' and the 'UI (User Interface)' and toggle if it's a 'filtered facet'.
To determine if you have a filtered facet, identify if you will present your facet as a numeric range. For example, if the price attribute is a numeric range, it should be set as a filtered facet.
Similarly, when configuring the attributes for custom sort options, the facets created should be synced with what has been created in the faceting configuration page in XO.
This page is found at Search → Configuration List → Configuration → Faceting (Filtering and Faceting ). If further information is required about configuring sortable attributes in XO, please click here.
For selecting a UI, please see an overview and table of the options below:
- Basic - This is a standard checkbox list.
- Datalist - This is a standard checkbox list with a search bar for facets with many options.
- Numeric Range - Consists of two input fields for minimum and maximum (if chosen, please ensure you've selected filtered facet).
- Custom - For developers to add their own custom implementation of a UI within their theme, for example, please see the Nyan cat example below:
| Attraqt App | BigCommerce Store |
Similar to custom sort options, once the facet has been created, it will seamlessly reflect on the front end. Custom facets can be removed, updated, and reorganised via the Attraqt app admin page.
For reference, you can find the example of the 'nyan' cat custom facet implementation below, which you can also add to your theme:
import { FacetProps } from "@attraqt/bigcommerce-xo-react";
const FacetNyan = (props: FacetProps) => {
return (
<div className="xo__facet xo__facet__basic" data-facet-id={props.id}>
<h4 className="xo__facet__title">{props.title}</h4>
<ul>
{props.availableValues?.map((value, index) => {
return (
<li key={index}>
<img
src="https://c.tenor.com/dXMhBr1Y-ykAAAAi/nyan-nyan-cat.gif"
style={{
filter: props.selectedValues.includes(value.value)
? ""
: "grayscale(100%)",
cursor: "pointer",
}}
onClick={() =>
!props.isLoading && props.toggleSelectedValue(value.value)
}
/>{" "}
<label
onClick={() =>
!props.isLoading && props.toggleSelectedValue(value.value)
}
>
{value.value} ({value.count})
</label>
</li>
);
})}
</ul>
</div>
);
};
export default FacetNyan;
Next step: Troubleshooting
Comments
0 comments
Please sign in to leave a comment.