# How rules work

> What a GeoEngage rule is made of, when rules run, which one wins when several match, and how to test and publish one.

A rule says who should see something different, and what. Everything a visitor sees change on your site comes from a rule.

## What a rule is made of

Open **Rules → Add New Rule**. The editor has the same four parts for every rule:

| Part | In the editor | What it decides |
| --- | --- | --- |
| Name and switch | **Basic Information** | What the rule is called in reports, and whether it's on. |
| Conditions | **When visitor matches** | Who the rule is for. See [Conditions](https://geoengage.app/docs/rules/conditions). |
| Action | **Then perform this action** | What those visitors see. One action per rule. See [Actions](https://geoengage.app/docs/rules/actions). |
| Advanced settings | **Schedule**, **A/B Testing**, **Widget Enhancements**, **Notes** | When it runs, how it's measured, how it appears. See [Timing and frequency](https://geoengage.app/docs/rules/timing) and [A/B tests](https://geoengage.app/docs/rules/ab-tests). |

A rule with no conditions matches every visitor.

## When rules run

The widget checks every rule on each page view, and again on each route change in a single-page app. For each rule whose conditions match, it runs the action — straight away, or when the rule's [trigger](https://geoengage.app/docs/rules/timing), such as exit intent or scrolling, happens.

A rule whose action already showed can be held back by its [display frequency](https://geoengage.app/docs/rules/timing#display-frequency), for example *Once Per Session*.

## When several rules match

All of them run, in priority order. Priority is the rule's position in the **Rules** list: drag rules to reorder them, with a single site selected. The rule at the top, `#1`, goes first.

Order matters when two rules change the same element. The higher-priority rule claims it and the other rule's action is skipped for that element, so a visitor never sees two rules fight over one headline.

## Publishing

Saving a rule keeps a draft. Your site is only ever sent published rules, so nothing changes for visitors until you choose **Save & Publish**.

The editor tells you where a rule stands: if it says visitors still see an earlier version, the rule has changes that aren't live yet. Switching a rule off in the **Rules** list takes it off your site.

## Before you publish

- **The preview** next to the action settings shows what the action looks like as you edit it.
- **Pick an element on your site** (next to any selector field) lets you click the element a rule should change on your live site, instead of writing a CSS selector. It uses a bookmark you add once.
- **Test Sandbox** in the dashboard loads the widget with your site's key, so you can watch rules run without touching your live site.
- **`data-debug="true"`** on the tag logs every rule check to the browser console. See [Debugging](https://geoengage.app/docs/widget#debugging).

---

Source: https://geoengage.app/docs/rules
