# Smart 404

Smart 404 shows search results on your "page not found" page. It searches for the words in the broken URL, so a visitor who follows an outdated link to `/beef-burgers` gets results for "beef burgers" instead of a dead end.

**Where to find it:** your `ss360Config`, or **Design & Publish** → [**Advanced**](https://app.sitesearch360.com/pluginConfiguration?tab=advanced-configuration) → **Configuration** → **Plugin Configuration** if you use the Design & Publish snippet

See it in action on the [live example](https://docs.sitesearch360.com/beef-burgers).

***

## How the query is built

Site Search 360 takes the last part of the URL path, drops a file extension such as `.html` or `.php`, removes "404", and turns hyphens into spaces. The domain, the folders before it and the query string are ignored. For example, `/shop/beef-burgers.html` searches for "beef burgers".

***

## Add Smart 404 to your site

Add a `smart404` object to your configuration:

```
var ss360Config = {
   ...,
   smart404: {
      identifier: 'Page not found', // text in the page title that marks a 404 page
      resultSelector: '#ss360-404', // element the results are shown in
      caption: 'Try going here instead:' // heading above the results
   }
};
```

| Setting          | What it does                                                                                                                       | Default                     |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| `identifier`     | Text in the page's `<title>` that marks it as a 404 page. Upper and lower case don't matter, and the title only has to contain it. | `'Page not found'`          |
| `cssIdentifier`  | A CSS selector instead: the page is a 404 page when the element exists. Overrides `identifier`.                                    | —                           |
| `resultSelector` | The element the results are shown in. If it doesn't exist on the page, results open in a layer.                                    | `'#ss360-404'`              |
| `caption`        | The heading above the results.                                                                                                     | `'Try going here instead:'` |
| `num`            | How many results to show, up to 12.                                                                                                | `12`                        |

To see what Smart 404 does on your site, go to [**Analytics**](https://app.sitesearch360.com/analytics/query-logs). The Smart 404 Queries table lists the queries it searched for, and Smart 404 Pages lists the broken URLs it ran on, most frequent first, so you know which links to fix or redirect. Smart 404 searches are kept out of Popular Queries, Zero Result Queries, Popular Results and All Queries. More in [Smart 404 in Search Analytics](https://docs.sitesearch360.com/dashboard-analytics.md#smart-404).

The configuration of the live example:

```
window.ss360Config = {
    siteId: '83460', // your site ID
    searchBox: {
        selector: '#searchBox' // your search box
    },
    smart404: {
        caption: 'We couldn\'t find what you were looking for but these results might help',
        identifier: 'page not found',
        resultSelector: '#ss360-404'
    }
};
```
