> For the complete documentation index, see [llms.txt](https://partner-docs.covergenius.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://partner-docs.covergenius.com/elements/guides/displaying-an-offer.md).

# Displaying an Offer

Show an offer panel on your page with a single placement.

### Before you start

* Install the SDK. See Installation.
* Make sure your backend calls Create Offer and returns the full response to the browser.

### Show the panel

{% stepper %}
{% step %}
**Add the element**

Add `<cg-elements>` where the panel must appear.

{% code title="index.html" %}

```html
<cg-elements></cg-elements>
```

{% endcode %}

The tag name is fixed.
{% endstep %}

{% step %}
**Register the SDK**

Call `registerElements()` once for each page. Do this before you call `getElement()`.

{% code title="main.js" %}

```js
import { registerElements, getElement } from '@covergenius/elements';

registerElements({ environment: 'production' });
```

{% endcode %}

`registerElements()` is safe to call more than once.
{% endstep %}

{% step %}
**Render the offer**

Get the instance and call `render()` with the Create Offer response.

```js
const cgElement = getElement();

cgElement.render(offerResponse);
```

`render()` accepts the complete response. Do not remove the `presentation`, `content`, `products`, or `product_rules` fields.
{% endstep %}

{% step %}
**Listen for events**

Add handlers before or after `render()`. The SDK keeps them either way.

```js
cgElement.on('ready', () => {
  // The panel is visible.
});

cgElement.on('change', ({ selectedOption, selectedProductIDs, declined }) => {
  // The customer chose an option.
});

cgElement.on('error', ({ code, message }) => {
  // The SDK hid the panel.
});
```

See Handling Selection for the event payloads.
{% endstep %}
{% endstepper %}

### Update the offer

Call `render()` again with a new response. The SDK renders the panel again and removes options that no longer exist. Call it when the quote changes, for example when the customer changes the trip dates.

```js
cgElement.render(updatedOfferResponse);
```

Each `render()` call replaces the previous response. The SDK does not merge responses.

### What the customer sees

The panel has five sections. They show from top to bottom.

| Section       | Content                             |
| ------------- | ----------------------------------- |
| `header`      | Title, icon, optional badge         |
| `top_body`    | Sub-heading, benefit lists, notices |
| `input_body`  | Options, price, selection controls  |
| `bottom_body` | Trust signals and testimonials      |
| `footer`      | Legal disclaimer and logo           |

Cover Genius chooses which sections and variants your offer shows. See Layouts and Sections.

### Remove the panel

Call `unmount()` when your page removes the placement for good.

```js
cgElement.unmount();
```

`unmount()` clears the handlers, the selection, and the state. The SDK hides the element but does not remove it from your DOM. Your code owns the element.

A `render()` call on an unmounted client does nothing. Call `getElement()` again to get a new client.

### If nothing shows

* Check that you called `registerElements()` before `getElement()`.
* Check that the response has a non-empty `presentation` field.
* Register an `error` handler and read the `code`.

See [Errors and Troubleshooting](https://partner-docs.covergenius.com/elements/reference/errors-and-troubleshooting.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://partner-docs.covergenius.com/elements/guides/displaying-an-offer.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.
