> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.metalocator.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Scoping Categories by Country

MetaLocator allows you to refine the user experience by **scoping categories** and using **deep links** to display content filtered by specific countries. This ensures users see only relevant locations or records, improving usability and navigation.

---

## 1. Show Only Active Categories

The **“Show Only Active Categories”** setting, found under **Interface Builder > Search Form Settings**, limits the categories displayed in the search form to those **associated with existing locations**.

* Categories linked only to locations **excluded by interface data filters** will not appear.
* This ensures that users see only categories relevant to their current search or location filters, reducing clutter and confusion.

## Key Features

* **Context-Aware Display** – Only categories tied to currently visible locations appear in the search form, ensuring relevance for users.
* **Reduced Clutter** – Categories associated with excluded or filtered-out locations are hidden.
* **Dynamic Filtering** – Works with other interface data filters (e.g., country, region, or custom fields) to create a fully scoped experience.
* **Improved Usability** – By showing only applicable categories, users are guided toward meaningful selections, improving the search experience.

Learn more about [Category Grouping, Parent/Child Ordering, and Filtering](https://support.metalocator.com/en/articles/1653961-category-grouping-parent-child-ordering-and-filtering#h_74e6155e3b).

---

## 2. Deep Linking by Country

**Deep linking** allows you to create URLs that automatically filter records based on certain criteria, such as country. This is particularly useful when sharing links externally or embedding maps on websites.

## Example Use Case

You want a page that displays only locations in **Canada**, and the search form should show **only categories associated with those Canadian locations**.

* For example, your global dataset may include locations in multiple countries with categories like **Retail**, **Co-Op**, and **Commercial**.
* If only **Retail** locations exist in Canada, then the search form for the Canada page should show **only Retail**, hiding Co-Op and Commercial categories that exist in other countries.

Using deep linking in combination with **Show Only Active Categories** ensures users see only the relevant locations and categories for Canada, avoiding irrelevant options from other countries.

**Note:** You can also use **script-based implementations** so the URL does not contain the country parameter. Instead, the filter can be applied directly on the page via JavaScript, keeping URLs clean while still pre-filtering locations and categories.

## Steps to Configure

1. Identify the **Country field** in your MetaLocator setup.
2. Create a URL with the proper query parameters for country and category (if using standard deep linking).

* Example format:

```
https://yourdomain.com/locator?country=Canada
```
3. Enable **Show Only Active Categories** in the search form settings to ensure only categories linked to Canadian locations appear.
4. Test the link or script implementation to ensure it filters correctly and displays only Canadian locations and their associated categories.

Learn more about [Deep Linking and Dynamic Options](https://support.metalocator.com/en/articles/1656158-deep-linking-and-dynamic-options#passing-javascript-variables).

## Benefits

* Users can **directly access** relevant locations without manually selecting filters.
* The search form shows **only applicable categories**, improving clarity and usability.
* Works seamlessly with Active Categories to provide a fully scoped experience.

---

## 3. Combining Active Categories + Deep Linking

By using **Show Only Active Categories** and **Deep Linking** together, you can:

* Present users with **pre-scoped search interfaces** based on country or other criteria.
* Limit available categories to only those relevant to the current interface filters and data.
* Share URLs that direct users to exactly the content they need, enhancing usability and reducing unnecessary clicks.

## Example Workflow

1. Enable **Show Only Active Categories** in the search form settings.
2. Create a deep link URL that includes the **country parameter** (e.g., Canada).
3. Test the URL to verify that only active categories and relevant records appear.
4. Use this URL on your website, marketing campaigns, or internal dashboards to streamline access.

---

## 4. Best Practices

* **Use Clear Category Names** – Ensure category names are descriptive and consistent across regions.
* **Test Deep Links Thoroughly** – Verify that URLs display the correct scoped results on all devices.
* **Combine with Other Filters** – Active Categories can work with other filters, such as location, country, or custom fields, for precise scoping.
* **Document Your Scoping Rules** – Keep a reference of which categories are active under different filters to aid maintenance.

---

By combining **Show Only Active Categories** with **Deep Linking by Country**, MetaLocator allows you to create a highly tailored search experience, making it easy for users to find exactly what they’re looking for while keeping your interface clean and efficient.