> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/magento/sdk-v4.x/sdk-v4.x/web-component-integration.md).

# Web Component integration

## Web Component integration

Enable or disable web components from the Magento configuration page.

Templates are located in:

```
src/view/frontend/templates/ff
```

Module styles are located in:

```
src/view/frontend/web/css/source/ff
src/view/frontend/web/css/source/_module.less
```

Magento uses Less for source styles. Integrate templates anywhere in the shop, preferably through Magento layouts.

```xml
<referenceBlock name="top.search">
    <action method="setTemplate" ifconfig="factfinder/general/is_enabled">
        <argument name="template" xsi:type="string">Omikron_Factfinder::ff/searchbox.phtml</argument>
    </action>
    <block class="Magento\Framework\View\Element\Template" name="factfinder.suggest" as="suggest" ifconfig="factfinder/general/is_enabled" template="Omikron_Factfinder::ff/suggest.phtml" />
</referenceBlock>
```

You can instantiate a block through the Magento Layout API. Layout configuration remains the recommended approach.

### Communication element

The `ff-communication` element is defined in `src/view/frontend/templates/ff/communication.phtml`. Its view model is `src/ViewModel/Communication.php`.

The default layout adds this template to the `after.body.start` container. Keep it included. The module cannot work without it.

{% hint style="warning" %}
Avoid overriding both the communication template and its view model.
{% endhint %}

### Searchbox

When the integration is active, the FACT-Finder search box replaces the standard Magento search.

The template is located at:

```
src/view/frontend/templates/ff/searchbox.phtml
```

Searches redirect to the FACT-Finder-powered Magento search results page. FACT-Finder adds relevant details, including the channel and query, to the URL.

The search result layout is defined in:

```
src/view/frontend/layout/factfinder_result_index.xml
```

It includes templates such as `ff-record-list` for search results.

### Request flow and proxy

By default, search and suggest requests go directly to FACT-Finder. Enable the proxy when you need to modify request parameters or responses in Magento.

The proxy controller is located at:

```
src/Controller/Proxy/Call.php
```

It forwards the request to FACT-Finder, processes the response, then returns it to the frontend. Add an `afterExecute` plugin to enrich returned data.

{% hint style="warning" %}
Proxying adds Magento and HTTP-server processing to every request. Enable it only when required.
{% endhint %}

### Category pages

The module preserves Magento category URLs for SEO. It uses standard Magento routing and custom FACT-Finder search parameters.

When a user opens a category page, a search request starts immediately through the `search-immediate` communication parameter. Enable the category-pages option in **Main Settings**.

### Tracking

The module tracks these events through the Web Components API:

* Product clicks
* Add-to-cart events
* Completed orders
* Customer logins

For product clicks, use the `data-redirect` directive in the record template. Add-to-cart tracking uses `src/view/frontend/web/js/catalog-add-to-cart-mixin.js`. Keep Magento's base `catalog-add-to-cart.js` enabled so the mixin applies.

Checkout tracking uses `ff-checkout-tracking` in `src/view/frontend/templates/ff/checkout-tracking.phtml`. This template extends the `checkout_onepage_success` layout. Add it to your own checkout layout if you do not use that layout.

Use `src/ViewModel/Order.php` to provide the order data. Login tracking uses the `ffcommunication` customer-data section configured in `src/etc/frontend/sections.xml`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/magento/sdk-v4.x/sdk-v4.x/web-component-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
