> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/capturing-preferences-from-push-buttons.md).

# Capturing Preferences from Push Buttons

Let users answer from a push button and store their choice as a profile attribute.

This recipe shows how to send a push with buttons that store the choice of the user in a profile attribute when the user taps a button. The preference is collected inside the notification, so the user does not need to open a form.

## When to Use

This recipe fits short questions, such as a favorite category or a feedback choice, where the answer should be saved on the profile and used later for targeting.

## Prerequisites

* REST API key of the application
* A button set created in the panel under **Settings > Button Sets**. Note the ID of the button set.
* The click action of each button set to **Open App**. The attribute is set after the push open event in the application.
* The profile attribute to set, defined in the panel

## Step 1: Send the Push with a Button Set

Reference the button set by `id` in `buttonSet`, and list one entry per button in `setAttrOrTag`. The key of each entry is the name of the button. `setOnClick` is `PROFILE_ATTR`, `attrName` is the attribute to set, and `attrValue` is the value that the tap stores.

```bash
curl https://restapi.netmera.com/rest/3.0/sendBulkNotification \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "message": {
    "title": "Pick Your Favorite",
    "text": "Which category do you like most?",
    "platforms": ["ANDROID"],
    "buttonSet": {
      "id": 4,
      "setAttrOrTag": {
        "Shoes": {
          "setOnClick": "PROFILE_ATTR",
          "attrName": "Favorite Category",
          "attrValue": "Shoes"
        },
        "Bags": {
          "setOnClick": "PROFILE_ATTR",
          "attrName": "Favorite Category",
          "attrValue": "Bags"
        }
      }
    }
  },
  "target": {
    "sendToAll": true
  }
}'
```

**Expected result:** HTTP 200 with a `notificationKey`.

## Step 2: Use the Same Buttons in a Notification Definition

The same `buttonSet` object works in `createNotificationDefinition`, so a reusable notification can collect the same answer. See [Sending Transactional Push Notifications to a Single User](/netmera-developer-guide/api-documentation/recipes/sending-transactional-push.md) for the definition flow.

## Step 3: Read the Attribute Back

After a user taps a button, verify the stored value with `getProfileAttributes`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getProfileAttributes?extId=user_1001' \
  --header 'X-netmera-api-key: <API_KEY>'
```

**Expected result:** The `profile` object contains the attribute with the value of the tapped button.

## Verification Checklist

* The button set exists in the panel and `id` matches its ID
* The keys in `setAttrOrTag` match the button names of the button set
* The click action of each button is **Open App**
* `attrName` refers to an attribute that is defined in the panel
* For platform-specific deliveries, the platforms are specified separately

## Related Pages

For all button options, see the Custom Button and Set Profile Attribute or Tag with Button Set sections of the [Notifications](/netmera-developer-guide/api-documentation/rest-api/notifications.md) page in the REST API documentation. To target users by the collected attribute, see [Targeting a Push Campaign by Segment or Profile Attribute](/netmera-developer-guide/api-documentation/recipes/targeting-by-segment-or-profile.md).


---

# 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://user.netmera.com/netmera-developer-guide/api-documentation/recipes/capturing-preferences-from-push-buttons.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.
