ChangeUp
News & UpdatesCompany
  • ChangeUp DMS
    • Platform Overview
      • Setup a ChangeUp DMS account
    • Implementation Overview
    • Widget Setup
      • Create a widget
      • Configure Donate-at-Checkout
      • Install widget
      • Implement the post-checkout webhook
      • Test and Live Environments
      • Deactivating a widget
      • Promoting a widget
      • Checkout Preview
    • Reporting
      • Viewing Reports
      • Download Data
      • Embed Reports
      • Using Report Filters
      • Canceling a Transaction
      • View transactions details
    • Donation Invoicing
  • Account Settings
    • Edit Company
    • Manage Users
      • Invite Users
      • Two-factor Authentication
      • Reset MFA
      • Forgot Password
      • Invite users to my account
      • Resending a user invitation
      • Deleting a user
    • View Activity Logs
    • API Key
    • Billing Information
    • Create API Keys
  • RESOURCES
    • APIs
    • Security Practices
Powered by GitBook
On this page
  • JavaScript Embeddable Widget
  • Event listeners
  1. ChangeUp DMS
  2. Widget Setup

Install widget

PreviousConfigure Donate-at-CheckoutNextImplement the post-checkout webhook

Last updated 1 year ago

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.

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:

<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>
Integration page showing embed code and widget preview.