Skip to main content

Configuring, Troubleshooting, and Optimizing Data Source Rules in Rebuy

Configure Rebuy data source rules using IF, THEN RETURN logic. Use Equals vs. Contains Any correctly, control rule order with Exit If Matched, set product caps, and troubleshoot missing products, out-of-stock filters, and exclusion filter behavior.

Written by Tom

Data Sources are the rules engine behind every Rebuy widget. Each data source rule follows an IF, THEN RETURN structure, where the IF condition determines when the rule fires and the RETURN section determines what products surface. This article covers how to configure data source rules correctly, troubleshoot the most common issues, and optimize rule logic so widgets return the right products on every page.

Configuring Data Source Rules

A data source rule has three core parts: the anatomy of the rule itself, the logic that combines conditions, and how the rule's output is capped at the widget level. Each is configured separately.

Anatomy of a Data Source Rule

Every data source rule has two sides: the IF condition that determines when the rule fires, and the RETURN side that determines what products surface.

IF condition components:

  • Object: Product, Cart, Customer, Country Code, etc.

  • Attribute: Product Tag, Product Vendor, Product Handle, etc.

  • Operator: Contains Any, Does Not Contain Any, Equals, etc.

  • Value: the specific tag, ID, or text being checked.

(Screenshot example above of the Data Source rule editor's IF dropdown listing the available IF condition components)

Then RETURN options:

  • Input Products: returns the products passed in as input (typically cart contents or the PDP product).

  • No Products: returns nothing. Useful for explicitly suppressing output when a condition matches.

  • Specific Product: pins one or more products to surface in the widget.

  • Products with Tags: returns products matching one or more product tags.

  • Products with Matching Metafields: returns products whose metafield values match the rule criteria.

  • Endpoint: returns products from a Rebuy-managed feed such as Recommended (AI), Top Sellers, Buy It Again, Recently Viewed, or Similar Products (AI).

  • Products In Metafield: returns products referenced inside a metafield (such as a product list metafield).

(Screenshot example above of the Data Source rule editor's Return dropdown listing the available product return options: Input Products, No Products, Specific Product, Products with Tags, Products with Matching Metafields, Endpoint, and Products In Metafield.)

Completed Data Source Rule example:

A complete rule reads as IF [Object] [Attribute] [Operator] [Value], THEN RETURN [type and value].

Screenshot example above of a fully configured data source rule with the IF condition (Object, Attribute, Operator, Value) and the RETURN (return type and value).

Combining Conditions with AND or OR

The IF section of a data source rule combines multiple objects using AND or OR. The choice changes when the rule fires.

Example:

Rule 1: 
IF cart subtotal is greater than $49.99 AND country code equals US,
RETURN Collection "Free Shipping Gifts"

Rule 2:
IF cart subtotal is greater than $49.99 OR country code equals US,
RETURN Collection "Free Shipping Gifts"

Rule 1 only fires when both conditions are true.

Rule 2 fires when at least one condition is true.

How Data Source Rules Are Evaluated

Data source rules are evaluated top to bottom. If multiple rules match, products from all matching rules are merged into the widget's return set, unless Exit If Matched is enabled on an earlier rule. See the Data Source Rule Order and Priority section below for details on how rule order interacts with Exit If Matched.

Max Number of Products Displayed

For every widget connected to a Data Source, the Widget editor's Max Number of Products displayed slider caps the total number of products a widget returns from its data source, regardless of how many rules match. The slider is located in the widget editor's DATA SOURCE section and ranges from 1 to 20. Once the cap is hit, no additional matching rules will contribute more products.

To raise or lower the product count, adjust the slider and save the widget.

(Screenshot example above of the Widget editor's DATA SOURCE section with the Max Number of Products displayed slider.)


Checking and Switching Which Data Source Is Connected to a Widget

Every Rebuy widget pulls its products from one data source at a time. Confirming which data source is connected, and switching to a different one, can be done from two places: the data source editor or the widget editor.

Check From the Data Source Editor

Open the data source from Rebuy Admin > Data Sources > select your data source. At the top of the editor, the Connected Widget(s) header lists every widget currently using that data source. Each widget is a clickable link that opens the widget editor in a new tab.

If the Connected Widget(s) header is empty, the data source is not connected to any widget and will not return products on the storefront until it is selected inside a widget.

(Screenshot example above of the Edit Data Source page with the Connected Widget(s) header highlighted at the top, showing the connected Widget link.)

Check and Switch From the Widget Editor

Open the widget from Rebuy Admin > Merchandising Widgets > select your widget. The DATA SOURCE section on the left shows the data source currently connected to the widget, including its ID.

To switch to a different data source, click the dropdown and select another data source from the list. To open the connected data source in a new tab and edit its rules, click the Edit link next to the DATA SOURCE header.

Save the widget after switching data sources for the change to take effect on the storefront.

(Screenshot example above of the widget editor's DATA SOURCE section with the connected data source name and ID displayed in the dropdown, and the Edit link visible next to the DATA SOURCE header. Use the dropdown to switch data sources and the Edit link to open the connected data source editor page.)


Using 'Equals' vs. 'Contains Any' in Data Source Rules

Choosing the wrong operator is the single most common data source rule misconfiguration.

Equals is a strict match. The condition is only true when the input matches the rule's values exactly, with nothing extra. If the rule is IF Products Equals A, B, the cart or page context must contain only A and B and nothing else for the rule to fire.

Contains Any is flexible. The condition is true if any of the listed values is present in the input. IF Products Contains Any A, B fires whenever A or B is in the cart, regardless of what else is there.

This distinction matters most on cart-based widgets and Product Page (PDP) widgets:

  • On a Product Page (PDP) widget, IF Products Equals X, Y, Z will never fire because a PDP can only have one input product. Use IF Products Contains Any and select all matching variants.

  • On a cart widget, IF Products Equals X, Y will only fire on a cart that contains exactly X and Y. Use IF Products Contains Any if you want the rule to fire whenever any of those products is in the cart.

The same logic applies to product tags. IF Product Tags Equals "sale" only matches products tagged with only "sale" and nothing else. IF Product Tags Contains Any "sale" matches any product carrying the "sale" tag alongside others.

(Screenshot example above of a data source IF products rule's Operator dropdown expanded, showing the Equals and Contains Any options alongside other operators like Does Not Contain Any and Does Not Equal.)


Data Source Rule Order and Priority

Data source rules are evaluated from top to bottom. The order of rules in the data source determines which one matches first and whether subsequent rules still get a chance to run.

The Exit If Matched setting controls how rule execution continues after a match. When toggled on for a rule, no rules below it will run once that rule's IF condition is satisfied. This is useful when a specific override should take priority over more general fallback rules.

By default, widgets refill themselves with new products as items are added to the cart. To stop a widget from refilling after a customer adds a product, enable Exit If Matched on the matching rule.

If Rule 1 returns a collection of 5 products and the connected Widget's Max Number of Products displayed slider is set to 10, the data source rules below Rule 1 will continue to run and fill the remaining 5 slots, unless Exit If Matched is enabled.

Place specific overrides at the top of the rule list and general fallback rules at the bottom.

(Screenshot example above of a data source rule with the Exit If Matched toggle highlighted in the on position. When enabled, no rules below this one will run once this rule's IF condition is matched.)


Troubleshooting Common Data Source Rule Issues

Widget Installation and Visibility

Before investigating data source rules, confirm the widget itself is installed and rendering using Rebuy Preview Mode. Click the REBUY DATA button to view all installed widgets and their statuses. See Use Rebuy Preview Mode to Diagnose Widget Status

A widget status of READY means the widget is installed and rendering. If it's still not visible on the page, the most common causes are: Live Mode is off (the widget is still in Preview Mode), the datasource isn't returning products, a display setting of "none" in the Layout tab, or a Dynamic Placement setting overriding the App Block position.

A status of INITIALIZING or REINITIALIZING means the widget failed to render mid-load. The three most common causes are a failed network request, a missing container element in the page's HTML, or a JavaScript conflict from custom code in the widget's or Smart Cart's callback boxes.

A status of HIDDEN means the widget loaded successfully but a built-in condition is suppressing it. The most common cause is a view limit reached on the widget's View Options settings.

Note that post-purchase widgets, checkout widgets, and Thank You / Order Confirmation page widgets will not appear in Preview Mode's Rebuy Data panel.

For more details see Why Isn't My Widget Showing?

Screenshot example above of Rebuy Preview Mode with the Rebuy Data panel open, showing installed widgets and their statuses (READY, INITIALIZING, HIDDEN).

Data Source Product Visibility Issues

If a widget renders but shows no products, work through these checks using the Data Source Previewer (Rebuy Admin > Data Sources > select your data source > Preview Ruleset). The Datasource Previewer is a testing tool that lets you simulate different customer scenarios and see what products your datasource rules would return, before anything goes live. For a full walkthrough, check out the Help Center guide: Previewing Data Sources

(Screenshot examples above showing how to access the Data Source Previewer simulator from the Preview Ruleset button inside a data source editor. The Data Source Previewer simulates page, cart, and customer context and shows which rules match and what products return.)

Rules not matching the current page context. Data source rules are evaluated against the page the widget is on. If a rule targets a specific product, collection, or URL that doesn't match the current page, no products will return. Use the Previewer to simulate the page context.

Out-of-stock products being filtered out. If the data source has Filter out of stock products enabled and the intended products are OOS, the widget will have nothing to display. See the Out-of-Stock Filter Behavior in Data Sources section below for full details.

IF condition not matching on a Product Page (PDP) widget. If the IF rule is scoped to a specific variant on a Product Page, Dynamic Bundle, or Add-On widget, Rebuy cannot match it because PDP widget types evaluate the IF condition using the product ID, not the variant ID. See the Specific Product Selection in Data Source Rules section below for the fix.

Wrong Shopify product status. Rebuy evaluates each product's Shopify lifecycle status at query time, and the result depends on both the status and the type of return used:

  • Active: returned in all data source responses.

  • Unlisted: filtered from AI, Top Sellers, collections, tags, and algorithmic ranking responses. Can still be surfaced via an explicit Specific Product return rule, which is useful for GWP and hidden SKU setups.

  • Draft: blocked from all data source responses, including explicit Specific Product returns. Draft products also cause a 422 error at Shopify checkout.

  • Archived: blocked from all data source responses.

Stale data source cache. If rules look correct but products still aren't returning, clear the cache from Rebuy Admin > Settings > Status > Data Source Cache > Clear Cache, or use the Clear Cache button directly within the data source editor.

Too many rules. Data sources with more than 30 to 50 rules can become slow to evaluate or fail to save. Split large data sources across multiple data sources and separate widgets.

Same products returning on every page. AI or endpoint-based rules that aren't scoped to the page context will return the same set of products regardless of where the widget appears. Add context-specific IF conditions to scope the rule.

Specific Product Selection in Data Source Rules

Product Page (PDP) widget types (Product Page, Dynamic Bundle, Add-On) evaluate the IF condition using the current page's product ID, not the variant ID. If the IF rule is scoped to a specific variant, Rebuy cannot match it and the widget will not render. The fix is to use IF Products Contains Any with all variants selected.

The RETURN side of the rule can still be variant-specific. The IF condition controls when the rule fires, while the RETURN controls which products and variants surface in the widget.

Only the Gift With Purchase Widget and the Smart Cart Tiered Progress Bar support automatically adding products to the cart based on data source rules. All other widget types display products for customer selection.

Out-of-Stock Filter Behavior in Data Sources

The data source includes two related filters under the Filters section:

Filter out of stock products prevents the data source from returning products with 0 inventory.

Filter out of stock variants prevents out-of-stock variants from appearing in the product's variant selector inside the widget.

These filters check global inventory only. Rebuy does not currently support filtering out-of-stock products by Shopify location or warehouse, so a product with inventory in one location but not another will still be returned globally.

When using Exit If Matched alongside a specific product return, the rule still counts as matched even if the returned product is out of stock (OOS). The widget will not skip to the next rule. For OOS fallback behavior, use a Collection return with Shopify's collection sorting set to a fixed order, and set Product Limit to 1. The collection-based approach allows the next in-stock product to surface automatically.

Filter Input Products Data Source Setting

The Filter Input Products setting prevents the data source from returning the products that were used as input to the rule. On cart widgets, products in the cart are input products. On product page widgets, the featured product on the Product Page (PDP) is the input product.

Enabling this setting prevents the widget from recommending the same product the customer is already viewing or has in their cart. This is the standard configuration for most cross-sell and upsell setups.

Screenshot example above of a data source's Filters section with the Filter Input Products checkbox highlighted.

There are two cases where the Filter Input Products setting should be turned off:

Selectable Gift With Purchase widgets. The widget uses cart contents as the input, and filtering would exclude the items already in the cart from the gift selection logic, breaking the flow.

Dynamic Bundle widgets where the merchant wants to return a specific variant of the input product. The setting filters out the PDP product entirely, including the desired variant.

Data Source Exclusion Filters

The Add Exclusion Filter option at the top of the data source allows you to exclude specific products or tags from every rule in the data source.

Screenshot example above of a data source with the Add Exclusion Filter option.

Use data source exclusion filters when:

  • You want to permanently keep a product (such as a gift card, sample, or service product) out of all recommendations regardless of which rule fires.

  • You want to exclude a category of products by tag while keeping all other rule logic the same.


Data Source Rules FAQ

What's the difference between 'Equals' and 'Contains Any' in data source rules?

In Rebuy data source rules, Equals is a strict match: the input must match the rule's values exactly with nothing extra. Contains Any is flexible: the rule fires if any of the listed values is present, even alongside others. Use Contains Any for most cart-based and Product Page (PDP) widget rules.

Can a Product Page widget data source rule fire on a specific variant?

A Product Page (PDP) widget data source rule cannot fire on a specific variant. The IF condition on Product Page, Dynamic Bundle, and Add-On widgets evaluates the product ID, not the variant ID. Use IF Products Contains Any with all variants selected. The RETURN side of the rule can still be variant-specific.

How do I prevent a widget from refilling after a customer adds an item?

To prevent a widget from refilling after a customer adds an item, enable the Exit If Matched setting on the matching data source rule. By default, widgets refill themselves with new products from subsequent matching rules as the cart changes.

How do I exclude a product from every rule in a data source?

To exclude a product from every rule in a data source, use the Add Exclusion Filter option at the top of the data source. The filter applies across all rules in that data source by excluding specific products or tags.

Does the 'Filter out of stock products' setting consider Shopify locations?

The Filter out of stock products setting does not consider Shopify locations. Rebuy filters out-of-stock products based on global inventory only. Location-specific or warehouse-specific filtering is not natively supported.

What happens when 'Exit If Matched' is enabled and the returned product is out of stock?

When Exit If Matched is enabled and the returned product is out of stock (OOS), the rule still counts as matched and the widget will not skip to the next rule. To handle OOS fallback, return a Collection (with Shopify's collection order set to a fixed sort) and set Product Limit to 1, instead of returning specific products in a single rule.

Why is my data source returning the same products on every page?

A data source returns the same products on every page when the rule's IF condition is not scoped to the current page context. AI and endpoint-based rules without context-specific IF conditions will return the same product set everywhere. Add a page-context IF condition (product, collection, URL, or tag) to scope the return.

How many data source rules can a widget have?

A widget's data source can technically hold many rules, but performance and save reliability degrade past 30 to 50 rules. Above that threshold, split the data source across multiple data sources and separate widgets.

What controls how many products a widget displays from its data source?

The Max Number of Products displayed slider controls how many products a widget displays from its data source. The slider is located in the widget editor's DATA SOURCE section and ranges from 1 to 20. Once the cap is hit, no additional matching rules will contribute more products. To raise or lower the product count, adjust the slider and save the widget.

How do I check which data source is connected to a widget?

To check which data source is connected to a widget, open it from one of two places. From the data source editor (Rebuy Admin > Data Sources > select your data source), the Connected Widget(s) header at the top lists every widget currently using that data source. From the widget editor (Rebuy Admin > Merchandising Widgets > select your widget), the DATA SOURCE section on the left shows the connected data source name and ID.

How do I switch a widget to a different data source?

To switch a widget to a different data source, open the widget from Rebuy Admin > Merchandising Widgets > select your widget. In the DATA SOURCE section on the left, click the dropdown and select a different data source from the list. Save the widget for the change to take effect on the storefront.

Why isn't my new data source rule reflecting on the storefront?

A new data source rule may not appear to take effect for several reasons. Work through these in order:

Browser-side caching. The simplest cause is the storefront serving a cached version of the page. Hard-refresh the storefront, clear the browser cache, or test in an incognito session before assuming the rule itself is broken.

Rebuy data source cache. Rebuy caches data source responses to improve performance. Clear the cache from Rebuy Admin > Settings > Status > Data Source Cache > Clear Cache, or use the Clear Cache button directly within the data source editor, then re-test.

Out-of-sync product data. If the rule references a product, tag, or collection that was recently added or modified in Shopify, Rebuy may not have the latest product data yet. Resync from Rebuy Admin > Settings > Status > Resync, or clear the Product Cache from the Cache Manager.

Invalid or conflicting rules. A rule above the new one may already be matching and exiting early via Exit If Matched, or two rules may contradict each other in ways that prevent the new rule from firing. Review the rule order and check for conflicting IF conditions.

Rule logic doesn't match the test context. The IF condition may be configured correctly but not actually matching the page, cart, or customer state being tested. Use the Data Source Previewer at Rebuy Admin > Data Sources > select your data source > Preview Ruleset to simulate the exact context and confirm whether the rule fires and what products it returns.

Where can I preview which products a data source rule will return?

To preview which products a data source rule will return, use the Data Source Previewer at Rebuy Admin > Data Sources > select your data source > Preview Ruleset. The Previewer simulates page context, cart state, and customer context, then shows which rules match and which products return.

Did this answer your question?