Chargebee Integration
Samantha avatar
Written by Samantha
Updated over a week ago

Overview

Reward advocates by giving them what they really want, a smaller bill. Using our seamless integration with Chargebee, you can configure your Friendbuy campaigns to use Chargebee Credit as the Reward Type.

This integrations allows you to add Friendbuy’s referral and sharing widgets to the Chargebee hosted checkout page for your subscription product or service, track conversions, and automatically deposit credit directly into an advocate’s Chargebee account to be applied against their next bill.

To learn more about Chargebee, please checkout their website.

Global Configuration

To get started, a one-time integration step is needed. Log into Friendbuy and from the Settings > Configurations > Integrations page, complete these steps:

  1. Click Add your Chargebee configuration.

  2. Fill in your Chargebee Site Name.

  3. A list of your sites is displayed when you first login to Chargebee. Once you’ve navigated to a specific site, the site name is also included in the subdomain of the URL (i.e. the portion of the URL directly preceeding “.chargee.com”).

  4. Fill in you Chargebee Access Key

  5. You can find your API keys in the Chargebee web interface under Settings > Configure Chargebee > API Keys.

  6. Click Save.

Adding Chargebee to a Campaign

Once your Friendbuy account has been configured to integrate with Chargebee, you can select which campaigns you’d like to use it with. You can add Chargebee as a Reward Type to a new campaign or update an existing campaign. To start, navigate to Referral and Sharing > Widgets

New campaign

  1. Select the Create Referral Widget button in the upper right-hand corner.

  2. Select Chargebee Credit from the Reward Type dropdown.

Existing campaign:

  1. Select your desired campaign from the list.

  2. Launch the widget builder by clicking the Edit button for the desired variant.

  3. In the right-hand menu bar of the builder, click the Edit button in the Reward Configuration section.

  4. Select Chargebee Credit from the Reward Type dropdown.

Validating Rewards

In addition to the standard fraud checks that can be configured for all campaigns, the Chargebee integration comes preconfigured with reward criteria that are particularly important for subscription-based business models. As part of our partnership with Chargebee, the integration offering provides out of the box validation to ensure that free or trial subscriptions are not cancelled before transitioning to a paid account.

To perform this validation, Friendbuy sets all eligible advocate rewards to pending for 30 days. On day 31, Friendbuy sends a reward notification to Chargebee so that their system can check that the referred friend’s account is active and their subscription is paid.

  • Note, the days to delay value can be adjusted if your subscription terms are not monthly or do not include an introductory trial.

These checks will be automatically configured for you when you select Chargebee Credit as your reward type for any campaign. Both the Validation URL and Days to Delay fields will be automatically populated.

  • Note, the validation URL is an endpoint hosted by Chargebee for each merchant.

If you would like to perform these checks using your internal system instead of Chargebee, you can do so by editing the Validation URL with an endpoint of your choosing. To learn more about what is required, please refer to our Reward Validation Callback help article.

  • Note, all campaigns configured with Chargebee require a Validation URL.

Passing Through Chargebee Conversions to Friendbuy

Chargebee conversions can be passed through to Friendbuy in one of two ways, depending on if you're using Chargebee's built-in Thank You page or if you're using your own custom Thank You page.

When using your own ‘Thank You' page

Include the following tracking javascript in your ‘Thank You' page to pass the conversions through to Friendbuy:

<script> window['friendbuy'] = window['friendbuy'] || [];

window['friendbuy'].push(['site', 'xxxxxxx']);

window['friendbuy'].push(['track', 'customer',

{ id: '{{customer.id}}',

chargebee_customer_id: '{{customer.id}}',

email: '{{customer.email}}',

first_name: '{{customer.first_name}}',

last_name: '{{customer.last_name}}'

} ]);

window['friendbuy'].push(['track', 'order',

{ id: '{{subscription.id}}',

amount: '{{invoice.purchase_amount}}',

email: '{{customer.email}}'

} ]);

(function (f, r, n, d, b, y) { b = f.createElement(r), y = f.getElementsByTagName(r)[0];b.async = 1;b.src = n;y.parentNode.insertBefore(b, y);})(document, 'script', '//djnf6e5yyirys.cloudfront.net/js/friendbuy.min.js'); </script>

The placeholders in the above javascript need to be replaced with the actual values of the customer conversion details. Please be sure to update the 'xxxxxxx' in the above code to the Site ID found in your Friendbuy Account. (Under Settings > Integration Code)

When using Chargebee's built-in Thank You Page:

To pass through conversions with Chargebee's built-in Thank You Page, you will have to add the data-cb-friendbuy-enabled tag in the Header Script or pass enableFriendbuyTracking as true while initializing Chargebee.init().

Here's an example:

<script src="https://js.chargebee.com/v2/chargebee.js" data-cb-friendbuy-enabled="true">

Reports

The status of all Chargebee rewards can be found in the Rewards report located at Referral & Sharing > Rewards. The Reward Details column of the report will indicate if a reward passed the validation performed by Chargebee.

If a reward is rejected due to validation or any of the other reward criteria you configure for the campaign, you have the option of manually overriding the rejection and setting the reward to Approved.

Rewards that are successfully paid out will be reflected directly in the advocate’s Chargebee account.

Other Integration Notes

  • To add a Friendbuy referral and sharing widget to your Chargebee hosted checkout page, please contact support@chargebee.com. In addition to the JavaScript needed to display a widget, Chargebee will also include Friendbuy's JavaScript that automates sending data about customers (SmartPixel) and orders (Conversion Tracker). Note, if you are hosting your own pages, please refer to these instructional videos on how to install the JavaScript snippets on your own (Widget, Smart Pixel and Conversion Tracker).

  • We strongly recommend that when setting up your Chargebee account, you select the option to use the customer id that is tracked and maintained in your system rather than using the auto-generated Chargebee customer id. This ensures that you, Friendbuy, and Chargebee all refer to a customer by the same unique identifier.

  • The customer id used by Chargebee is relayed to Friendbuy along with the new signup/order information passed from the Chargebee subscription checkout page.

  • The Chargebee subscription ID is the value used in Friendbuy as the order ID that is tracked for all conversions.

Did this answer your question?