Milly Software
InsightsRulesHow to Use Conditional Rules to Personalize Your Shopify Chat Widget
Rules··9 min read

How to Use Conditional Rules to Personalize Your Shopify Chat Widget

Control when, where, and how your chat widget appears with conditional rules — URL targeting, device detection, time-based visibility, and more.

V
Viet Le
co-founder · Milly Software

Why One-Size-Fits-All Chat Widgets Miss the Mark

Most Shopify stores install a chat widget with a single configuration: one greeting, one appearance, one set of behaviors across every page. The problem is that a customer browsing your homepage has fundamentally different needs than someone deep in a product page or about to check out.

A first-time visitor comparing options needs proactive help. A returning customer who's already had three conversations probably doesn't need a "Welcome! How can I help?" popup. Someone on mobile has less screen real estate than someone on desktop, and a chat bubble that feels helpful on a 27-inch monitor can feel intrusive on a phone.

This is where conditional rules come in. Instead of treating every visitor the same, you define rules that adapt the widget's behavior based on real context—the page they're on, the device they're using, how long they've been browsing, and more.

What Are Conditional Rules?

Conditional rules are logic that controls when, where, and how your chat widget appears based on a set of conditions you define. Think of them as "if this, then that" for your widget. Each rule consists of one or more conditions paired with an action—like showing the widget, hiding it, changing the greeting, or adjusting its position.

For example, a rule might say: "If the visitor is on a product page AND has been on the page for more than 30 seconds, show a proactive greeting that says 'Have questions about this product?'" Another might say: "If the visitor is on the checkout page, hide the widget entirely."

The power comes from combining multiple conditions. Rules are evaluated in priority order, and the first rule whose conditions all match is the one that takes effect. This gives you precise control over the customer experience without writing any code.

Types of Conditions You Can Use

Modern chat widget platforms support a range of condition types. Here are the most common categories and what each one unlocks:

URL-Based Conditions

URL conditions let you target or exclude specific pages on your store. This is the most commonly used condition type because different pages serve different purposes. You can match exact URLs, URL patterns with wildcards, or pages that contain a specific path segment.

  • Show on product pages — Match /products/* to display the widget wherever customers are evaluating a purchase
  • Hide on checkout — Exclude /checkout and /cart to reduce distractions during the conversion flow
  • Target collections — Match /collections/new-arrivals to offer help specifically where new inventory lives

Device-Based Conditions

Device conditions let you tailor the experience for mobile, tablet, and desktop users separately. Mobile shoppers account for 70%+ of e-commerce traffic for many stores, so it's worth considering their experience independently.

  • Mobile-only widget — Show the chat widget only on mobile if your analytics show mobile users have higher bounce rates and need more assistance
  • Desktop-only search bar — Use the full search bar format on desktop where screen space allows, but switch to a compact chat bubble on mobile

Time-Based Conditions

Time-of-day conditions let you adjust the widget based on the hour, which is especially useful if your store offers live handoff in addition to AI chat.

  • Business hours greeting — During 9am-5pm, greet visitors with "Our team is online! Ask me anything or request a human agent."
  • After-hours message — Outside business hours, show "We're offline, but our AI assistant can help with product questions, order status, and more."

Customer Behavior Conditions

Behavior conditions trigger based on what the visitor is actually doing on your site. These are powerful for engaging visitors at the right moment rather than immediately.

  • Time on page — Show the widget after a visitor has spent 30 seconds on a page, indicating genuine interest
  • Visit count — Trigger a proactive greeting after 3+ visits, when the visitor is clearly browsing but hasn't found what they need
  • Scroll depth — Show the widget after the visitor scrolls past 50% of a long product page, suggesting they're reading details but may have questions

Conversation Count Conditions

Conversation count conditions differentiate between first-time and returning visitors. A customer who's already used your chat widget multiple times has a different relationship with your store than someone discovering it for the first time.

  • First-time visitors — Show a welcoming introduction: "Hi there! I'm your AI shopping assistant. I can help you find the perfect product."
  • Returning visitors — Skip the intro: "Welcome back! What can I help you with today?"
  • Frequent users — After 5+ conversations, offer a loyalty incentive or route directly to premium support

Practical Use Cases with Examples

Theory is useful, but let's look at specific scenarios you can implement today. These are patterns we've seen work well across Shopify stores of different sizes and categories.

1. Proactive Product Page Assistance

Rule: If URL contains /products/ AND time on page is greater than 30 seconds, show a proactive greeting.

Why it works: A visitor who has been on a product page for 30 seconds is actively evaluating the product. They may have questions about sizing, compatibility, or shipping that are preventing them from adding to cart. A well-timed "Have questions about this product? I can help with sizing, specs, or compatibility" can be the nudge that converts a browse into a purchase.

2. Distraction-Free Checkout

Rule: If URL contains /checkout OR URL contains /cart, hide the widget.

Why it works: Once a customer has committed to checking out, you want a clean, focused experience. A chat bubble in the corner can distract or even cause accidental clicks on mobile. Hiding the widget on checkout pages keeps the funnel clean and reduces cart abandonment from unnecessary distractions.

3. Returning Visitor Recognition

Rule: If conversation count is greater than 0, show a personalized greeting like "Welcome back! Looking for something specific today?"

Why it works: Returning visitors already know what your chat widget does. They don't need the introductory pitch. A short, direct message that acknowledges their return feels more personal and gets them to their answer faster.

4. Mobile-First Engagement

Rule: If device is mobile AND URL is the homepage, show the widget with a compact greeting.

Why it works: Mobile users navigate differently. They're more likely to scroll quickly, less likely to use search, and more likely to bounce if they can't find what they need fast. Proactively offering AI assistance on mobile can guide these visitors to the right products before they leave.

5. High-Value Visitor Follow-Up

Rule: If conversation count is greater than 5, show a special message like "Thanks for being a frequent visitor! Use code LOYAL10 for 10% off your next order."

Why it works: Visitors who repeatedly engage with your chat widget are highly interested in your products. Rewarding their engagement with exclusive offers can push them over the conversion line. It also makes the chat experience feel personalized rather than generic.

How to Set Up Conditional Rules

Setting up conditional rules should be straightforward, even if you're not technical. Here's the general workflow:

  • Create a rule — Give it a descriptive name like "Product page proactive greeting" or "Hide on checkout." Clear naming makes it easy to manage rules as your list grows.
  • Add conditions — Each rule can have one or more conditions. Conditions use AND logic by default, meaning all conditions must be true for the rule to activate. For example, "URL contains /products/ AND time on page > 30s" requires both to be true.
  • Set the action — Choose what happens when the rule matches: show the widget, hide it, display a specific greeting, or switch between the widget formats.
  • Order your rules by priority — Rules are evaluated top to bottom. The first matching rule wins. Drag and drop to reorder them. Put your most specific rules at the top and your general fallback rule at the bottom.
  • Enable or disable rules — You can toggle individual rules on and off without deleting them. This is useful for seasonal rules (like a holiday greeting) that you want to reuse later.

Testing Your Rules

Rules that look right in a dashboard don't always behave the way you expect on the live site. Always test before going live:

  • Preview mode — Use your widget platform's preview or sandbox mode to test rules without affecting live visitors. Check different URLs, simulate mobile vs desktop, and verify that the correct greeting appears.
  • Test each condition type — If a rule has three conditions, test what happens when one condition fails. The rule should not fire if any condition is unmet.
  • Check priority order — If you have overlapping rules, make sure the higher-priority rule is the one that fires. A common issue is having a broad "show everywhere" rule above a specific "hide on checkout" rule, which means checkout visitors still see the widget.
  • Mobile testing — Always test on a real mobile device. Device detection in browser dev tools doesn't always match real-world behavior.

Common Mistakes to Avoid

Conditional rules are powerful, but they can backfire if overused or misconfigured. Here are the pitfalls we see most often:

  • Too many rules — Start with 3-5 rules and add more only as needed. Every additional rule increases complexity and the chance of conflicts. If you have 20 rules and something isn't working, debugging becomes painful.
  • Hiding the widget everywhere — It's tempting to hide the widget on page after page, but if it's hidden almost everywhere, your customers can't use it. Be intentional: hide on checkout, yes. Hide on every page except products? Probably too aggressive.
  • Conflicting rules — Two rules that match the same page but take opposite actions create unpredictable behavior. For example, a "show on all product pages" rule and a "hide on /products/gift-card" rule need to be in the right priority order—the more specific rule should come first.
  • Forgetting the fallback — If every rule has narrow conditions, some visitors may not match any rule. Always have a default "show the widget" rule at the bottom of your list to catch everything else.
  • Not testing on mobile — Device conditions can interact with URL conditions in unexpected ways. A rule that works perfectly on desktop may not fire on mobile if you've added a device condition to a different rule with higher priority.

Conditional Rules in Milly Chat

Milly Chat's conditional rules system (v2) supports 11 condition types out of the box: URL parameter, URL path, device type, referrer, time of day, visit count, conversation count, localStorage, time on page, scroll depth, and exit intent. Rules are created in a visual editor with drag-and-drop reordering for priority management—no code required.

Each rule supports multiple conditions with AND logic, toggle-based enable/disable, and a clear preview of what the rule does. You can set up rules like "show a proactive greeting on product pages after 30 seconds" in under a minute, and reorder priorities by dragging rules up or down.

Combined with Milly Chat's AI-powered product recommendations (powered by Claude Sonnet 4), knowledge base support, and conversation replay, conditional rules give you full control over how your chat widget engages visitors throughout their shopping journey—and the Impact analytics show whether a given rule actually moves conversions.

Frequently Asked Questions

Do I need to know how to code to set up conditional rules?

No. Most modern chat widget platforms, including Milly Chat, offer a visual rule builder. You select condition types from a dropdown, enter values, and drag rules to reorder priority. No JavaScript or Liquid templates required.

How many conditional rules should I start with?

Start with 3-5 rules. A good starting set is: (1) hide on checkout, (2) proactive greeting on product pages after 30 seconds, (3) different welcome message for returning visitors, and (4) a default "show the widget" fallback. Add more rules as you learn from your analytics which pages and behaviors matter most.

Can I show a different chat widget on different pages?

Yes. With URL-based conditions, you can show different greetings, quick questions, or even different widget formats on different pages. For example, you might show a search bar on your homepage and a chat bubble on product pages. Rules are evaluated per page load, so each page can trigger a different experience.

What happens if no rule matches?

If no rule matches, the widget falls back to its default configuration—typically showing with your standard greeting. This is why having a low-priority fallback rule is good practice: it makes the default behavior explicit and gives you a place to configure it.

Try Milly Chat

Want to see how this fits your store?
We'll set up a working session.

Get it on ShopifyTalk to sales →