How to pass Data to Chargebee Retention with Segment Analytics JS snippet?

Modified on: Sat, 1 Oct, 2022 at 12:16 AM


Pass Data to Chargebee Retention with Segment Analytics JS snippet


Chargebee Retention can receive your Segment data for enrichment by adding a few lines of code to your Chargebee Retention.JS snippet. We use Segment traits stored in your customer's browsers when they hit the cancel button. These traits can then be mapped in Field Mapping and used to personalize your Pages or define custom Audience in Chargebee Retention. 

<script type="text/javascript" src=""></script>
<script type="text/javascript">
if (window.Brightback) {
const Segment = analytics;
const userId = Segment.user().id();
const email = Segment.user().traits().email;
const segmentData = {
user: Segment.user().traits(),
group: ? :{}
app_id: "APP_ID",
email: email,
account: {
internal_id: userId,
custom: {
segment: segmentData,

 You can include Billing Enrichment with Segment Enrichment by also including your subscription_id: as a field in the JS and mapping it to the Subscription ID field under field mapping in Chargebee Retention. 

For help configuring your JS snippet to include Segment data, contact

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.