Docs

Growth

Chargebee Retention is now part of Chargebee Growth.New customers can find everything you need in Chargebee Growth documentation.Existing Chargebee Retention customers can continue to access the legacy Chargebee Retention documentationhere.

Installation Guide

Overview

Once you've configured pricing tables, in-app offers, or cancel pages, and their associated Plays in Chargebee Growth, you must integrate Chargebee Growth with your website or application to enable them to be displayed to your customers.

The setup includes integrating Chargebee.js on the frontend and, if needed, one of the Chargebee REST API SDKs on the backend. The following table summarizes the type of technical integration required based on your use case.

FeatureUse CaseIntegration Type
Pricing TableDisplay a specific Chargebee-hosted pricing table to new customers.Chargebee.js (low code)
Display a specific Chargebee-hosted pricing table for new or existing customers.Chargebee.js + Chargebee APIs
Use Plays to display a Chargebee-hosted pricing table dynamically based on customer context.Chargebee.js + Chargebee APIs
In-app OffersUse Plays to display Chargebee-hosted in-app offers to existing customers.Chargebee.js (low code)
Use Plays to display in-app offers with fully customized UX to existing customers.Chargebee APIs
Cancel PagesUse Plays to display full-page Chargebee-hosted cancel pages.Chargebee.js (low code) • Chargebee APIs

Chargebee.js provides you with a single frontend integration for all Chargebee-hosted features such as Cancel Page, Pricing Table, In-app Offers, and more.

In the next sections, we'll elaborate on the use cases summarized in the table above.

Pricing Tables

Display specific pricing tables to new customers

You can embed a specific pricing table in your website or application using Chargebee.js. This is the simplest, low-code approach for displaying a pricing table on your website or application.

See the Pricing Table Quickstart to do this.

Display specific pricing tables to new or existing customers

If you want to select the pricing table to be displayed based on the customer's session, you must select the pricing table using Chargebee APIs and use Chargebee.js to render it on your application.

See this tutorial to display specific pricing tables based on user sessions.

Display dynamic pricing tables for existing customers using Plays

For existing customers, you can also let Chargebee select the pricing table to be displayed based on customer context. You can do this by configuring pricing table plays. Plays help you setup targeting and deploy price experiments.

Follow this tutorial to render pricing tables using Chargebee Growth plays.

In-app offers

Display Chargebee-hosted in-app offers using Plays

The simplest solution is to show pre-built Chargebee-hosted in-app offers to your customers. This low-code solution lets you customize the offer experience in Chargebee Growth. Offers are shown automatically to users when trigger conditions are met. Offer views and dismissals by users are tracked automatically.

See the In-App Offers integration guide to set this up.

Display in-app offers with fully customized UX

For complete control over offer delivery and retention experiences, use the Chargebee Offers REST APIs:

  • Personalized Offers API: Pass customer details such as name, role, and subscription ID to get matching offer payloads that contain the content to display and the actions to take to fulfill the offer. Use these to render the offer with your own custom-built UI.
  • Offer Fulfillment API: When a customer accepts an offer, use this API to trigger fulfillment workflows such as creating a Checkout page or fetching a URL to redirect your customer to, depending on the processing type configured for the offer in Chargebee Growth.
  • Offer Events API: Enable offer analytics and reporting in Chargebee Growth by notifying Chargebee Growth when your customers view or dismiss offers.

Install the Chargebee client library for the appropriate language in your development environment to use these APIs.

Cancel pages

You can display cancel pages as full-page experiences to which you redirect customers to, or you can render them in an iframe in your website or application. There are two approaches for this:

Option 1: Frontend integration

Use Chargebee.js to launch cancel pages directly in your website or application UI. For more information, see the Cancel Page Quickstart.

Option 2: Backend integration

Use Chargebee REST APIs to create cancel pages and embed them in your website or application. For more information, see this API guide.

Appendix

Integrate Chargebee Retention.js (Deprecated)

Details

⚠️ Deprecated

This section provides the steps to integrate Retention.js, the older version of the Growth Solutions JS SDK. However, note that Retention.js is deprecated and does not receive any new updates. You should migrate to one of the above-mentioned Chargebee.js integrations as soon as possible.

Embed Chargebee Growth in your site or application

To ensure that Chargebee Growth is initialized correctly, you must embed a JavaScript snippet within your website or application such that it is automatically initialised on page load. Next, you need to create a new Growth instance by passing the application ID of your Chargebee Growth application.

To embed the script on your application or site:

  1. Identify a common location in your application where the snippet will load on every relevant page. We recommend embedding the java script snippet and making it available at a common location with your application to automatically initialize the Chargebee Growth instance.
    • If you have a single-page application, such as a React app, you can include our js in the index.html file. Doing so will automatically include the js code on all the pages.
    • If you have a multi-page application, you must include the js code on all the pages to load the js.
  2. Retrieve the Application ID for your Growth instance:
    • Log in to your Chargebee Growth site.
    • Extract the App ID from the browser URL. For example, if the URL is https://app.chargebee.com/retention/kav8jMaojO, then kav8jMaojO is the App ID.
  3. Add the following snippet to your site, replacing YOUR_APP_ID with the extracted App ID:
<script>
   (function ()) 
      const cbretention = new ChargebeeRetention({
      api_key: <YOUR_APP_ID>
   });
</script>

This step enables Chargebee Growth to identify users, sync subscription data, and direct them to the appropriate offer within Growth solution.

Initialize the Growth solution

Once the Chargebee Growth instance is created, you need to initialize the offer rendering solution by calling the init() function and passing user-specific details such as customer ID and email address to identify the logged-in user or customer.

To initialize the solution:

Add the following snippet, replacing the placeholders with actual user data:

(function () {
   const cbretention = new ChargebeeRetention({
       api_key: kav8jMaojO
   });

   cbretention.init({
       customer_id: "5634354", // Customer ID within the integrated billing site
       user: {
           email: "jdoe@fantasyworld.com", // Your end user's email address
           roles: ["engineer", "admin"], // End user's roles
       },
   });
})();

Your Chargebee Growth instance is now initialized and is ready to process user interactions. If you are using Growth solution alone, this step has you covered.

Set up cancel flows along with offer flows

To use Growth solution along with Chargebee Retention, and to address churn and automate successful retention campaigns, you need to initialize the cancel flows as well and additionally embed the cancel button on your web page. If you have embedded the Chargebee Retention.js snippet on your site or app already, you can proceed to configure a cancel button within your Growth solution to enable a seamless cancellation experience.

To set up cancel flows:

  1. Apply the id="bb-cancel" selector to the button or link users will click to initiate cancellation. For example: <button id="bb-cancel" href="">Cancel Subscription</button>.

  2. Chargebee Growth will automatically detect this button and direct users to their personalized cancel experience.

If the JavaScript cannot process the request, the button will default to the href URL assigned in the link.

The above implementation steps are all you need to get started and they typically take only a few minutes to complete. Please reach out to us if you have any questions.

Was this article helpful?