# How to enable Merchandising Reporting

Merchandising reporting lets you track the performance of your strategies (views, clicks, conversions) directly in Google Analytics 4 (GA4).\
To do this, you just need to make sure that Merch events are sent to your website’s DataLayer through the AB Tasty tag.

### Enabling Merchandising reporting

{% stepper %}
{% step %}

#### Check that the AB Tasty tag is installed

If you already have product recommendations running on your site, the tag is already there. There is no need for extra setup.
{% endstep %}

{% step %}

#### Configure analytics in your tag

Your **Technical Support Engineer (TSE)** or internal tech team simply needs to add this key to the `config.json` file of your tag configuration:

<pre class="language-json"><code class="lang-json"><strong>"analytics": {
</strong>  "merchandisingEventsToDataLayer": ["site"]
}
</code></pre>

{% hint style="info" %}
This automatically enables Merchandising events (`show`, `click`, `add_to_cart`, `convert`) to be pushed into your site’s DataLayer exactly like Recommendation events.
{% endhint %}
{% endstep %}

{% step %}

#### Make sure GA4 / GTM is set up

If your Recommendation reporting is already configured, Merch events will be captured the same way once the additional variables **`event_id`** and **`category_id`** are included. Otherwise, your TSE or internal tech team can follow the existing Recos GTM setup (same trigger, variables, and event structure) and add these two variables.
{% endstep %}

{% step %}

#### Test it

Open your site → open the browser console → type `dataLayer`.\
You should see events like:

```
{
  "event": "ab_recos_xxxx",
  "recos": {
    "action_id": "show",
    "reco_id": "xxxx",
    "item_ids": "[\"12345\",\"67890\"]"
  }
}
```

{% hint style="info" %}
If you see them, it means Merch events are being correctly sent to GA4.
{% endhint %}
{% endstep %}
{% endstepper %}

If you want to know more about the **Merchandising strategy reporting** **dashboard** with metrics like views, clicks, conversion rate, and top products, read [Merchandising Reporting](/recommendations-and-merchandising/getting-started/merchandising/merchandising-reporting.md)

{% hint style="info" %}
**Need help?**

Contact your **Technical Success Engineer (TSE)** to confirm or validate the configuration.
{% endhint %}

### How to setup HTML on your website ?&#x20;

To allow the AB Tasty tag to detect and send Merch events automatically, your merchandising banners must include specific HTML attributes.

If AB Tasty does not manage your frontend (custom site or CMS), your development team must add these attributes directly in the HTML of your merchandising banners.\
Each product container should include these attributes so the AB Tasty tag can detect and send events.

### Required attributes

| Attribute                                                      | Description                                                                                                                                                      | Example                                                        |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `data-category-id`                                             | Category identifier                                                                                                                                              | `<div data-category-id="jeans-homme">`                         |
| `data-merch-uuid` *(only mandatory for Merch deployed by API)* | <p>Strategy merch identifier</p><p></p><p>(<em>Both <code>data-merch-uuid</code> and <code>data-category-id</code> need to be on the same HTML element)</em></p> | `<div data-merch-uuid="62f1937c-d021-4911-972e-237b5413386h">` |
| `data-item-id`                                                 | Product identifier                                                                                                                                               | `<div data-item-id="SKU123">`                                  |
| `data-reco-click`                                              | User interaction type                                                                                                                                            | `<button data-reco-click="add_to_cart_item">`                  |
| `data-reco-debug="true"` *(optional)*                          | Enables debug mode in console                                                                                                                                    | `<div data-category-id="jeans-homme" data-reco-debug="true">`  |

### Event Actions available

| Action ID           | When is it triggered                                       |
| ------------------- | ---------------------------------------------------------- |
| `show`              | When the banner appears in the DOM                         |
| `go_to_page`        | When a product in the banner is clicked                    |
| `add_to_cart_item`  | When a user adds one product to cart                       |
| `add_to_cart_items` | When the user adds all recommended products (e.g. bundles) |
| `convert_xxx`       | When a conversion button is clicked                        |

{% hint style="info" %}
The tag automatically sends a `show` event as soon as an element with a `data-category-id` appears in the DOM.\
If you fill it asynchronously, make sure to add this attribute only after the items are rendered, otherwise the event will fire empty.
{% endhint %}

### How to configure GTM / GA4 ?

The configuration is the same as for Recommendations tracking, except that two additional variables must be added: **`event_id` and `category_id`** (see table below).\
If you already have Recommendation analytics events in GA4, you only need to include these two variables.

Otherwise, follow these steps:

{% stepper %}
{% step %}

#### Create a Trigger

* Go to **Triggers > New**
* Type: **Custom Event**
* Event name: `ab_recos.*`
* Check **Use regex matching**
* Apply to **All custom events**
  {% endstep %}

{% step %}

#### Create Data Layer Variables

Create these six variables:

| Variable name | Data Layer variable name |
| ------------- | ------------------------ |
| `reco_id`     | `recos.reco_id`          |
| `event_id`    | `recos.event_id`         |
| `item_ids`    | `recos.item_ids`         |
| `action_id`   | `recos.action_id`        |
| `category_id` | `recos.category_id`      |
| `item_id`     | `recos.item_id`          |

{% hint style="info" %}
You can access them in GTM via the data path `recos.VARIABLE_NAME`.
{% endhint %}
{% endstep %}

{% step %}

#### Create a GA4 Event Tag

1. Go to **Tags > New**
2. Tag type: **Google Analytics: GA4 Event**
3. Event name: `ab_recos`
4. Add your **Measurement ID** (from GA4 Admin > Data Stream)
5. Add the six variables above as **Event Parameters**
6. Trigger: the one created in step 1 (`ab_recos.*`)
   {% endstep %}
   {% endstepper %}

### Example event in the DataLayer

**Show event**

```json
{
  "event": "ab_recos_12345",
  "recos": {
    "category_id": "jeans-homme",
    "action_id": "show",
    "item_ids": "[\"SKU123\",\"SKU456\"]",
    "debug_mode": false
  }
}
```

**Click event**

```json
{
  "event": "ab_recos_67890",
  "recos": {
    "category_id": "jeans-homme",
    "action_id": "go_to_page",
    "item_id": "SKU123",
    "item_ids": "[\"SKU123\",\"SKU456\"]"
  }
}
```

### How to test my reporting tracking ?

1. Open your website
2. Open the **browser console**
3. Type:

   ```js
   console.log(dataLayer)
   ```
4. You should see events like `ab_recos_xxxx` containing `category_id`, `action_id`, and `item_ids`.

{% hint style="info" %}
If these appear → the tracking setup is working.\
You can then see results in GA4 > *DebugView*, and later in AB Tasty *Merch Reporting*.
{% endhint %}

### Notes & Limitations

* Merch Analytics is currently available **only for GA4**.
* Piano Analytics and Matomo are supported for Recommendations only.
* Merch and Reco events share the same event name (`ab_recos.*`) and GTM configuration.
* Activating this does **not interfere** with your existing analytics setup.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.abtasty.com/recommendations-and-merchandising/how-tos/how-to-track-performance/how-to-enable-merchandising-reporting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
