> For the complete documentation index, see [llms.txt](https://docs.changeup.com/app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.changeup.com/app/changeup-dms/widget-setup/install-widget.md).

# Install widget

## JavaScript Embeddable Widget

Once a widget is configured and saved, it is ready to be installed. The Integrate tab in the component Settings will provide the client-side JavaScript required to place the resulting embed code within the existing page layout.

The CSS is exposed within the Integrate section of the component for demonstration purposes. This should be integrated into the existing CSS structure within the destination application and can be modified to match the native styles of your platform or website.

Multiple donation widgets can be configured to handle different checkout flows (for example if one brand has multiple websites and wants to feature different charities on each), or A/B testing.

<figure><img src="https://814680633-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcH5SMrrvcoTMfHpSL60L%2Fuploads%2FVQ0TejVyk6bIbRSO8uCH%2F3.4%20dac%20Integrate-Integration.png?alt=media&amp;token=d901d6fa-ea9e-4864-8238-7944233853a1" alt=""><figcaption><p>Integration page showing embed code and widget preview.</p></figcaption></figure>

## Event listeners

In order to capture component actions, such as donation opt-in, opt-out, charity selected, etc., event listeners need to be set up. These event listeners will interact with your platform to add/remove/update the appropriate line items for the donation details.

For example, the cart subtotal needs to be sent to ChangeUp for RoundUp calculation to take place. Basic implementation code:

```html
<script async src="https://widget.changeup.com/changeup-donate-checkout.js"></script>

<script>

// listen for widget actions here
document.addEventListener('changeup-donate-checkout', function(event) {
  
  console.log('widgetState', event?.detail)  

  /* Widget state
  {
    "donateOpt": true, // whether they are opt-in or opt-out of the donation
    "causeId": "a051d439-8f97-471b-ab50-09...", // the id of the cause/charity that is selected
    "supersized": false, // whether supersized has been selected or not
    "userDonationAmount": .42, // what the user donation amount calculates to
    "partnerDonationAmount": 0 // what the partner donation calculates to
  }
  */

});

</script>

<!-- widget embedded here -->
<div
    data-island="changeup-donate-checkout"
    data-subtotal="$10.58"
    data-widget="2909be56-a106-42d5-9dd2-02a...."
    data-client="Client ID Here">
</div>
```


---

# 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.changeup.com/app/changeup-dms/widget-setup/install-widget.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.
