Docschargebeedocs

HomeBillingPaymentsRevRecGrowthReveal
Support

Product Updates


  • Release Notes

Getting Started Guide


  • Getting Started Guide

Managing Experiences


  • Getting to know the Experience Manager

Reporting


  • Reporting Overview

Chargebee Billing Integration


  • Chargebee Billing Integration Features

Settings and Installation


  • Navigating the Chargebee Retention Settings Page

Integrations


  • Integrations Overview
    • Chargebee Retention Billing Integrations
    • Stripe Billing Integration
    • Recurly Billing Integration
    • Integrating Chargebee Retention with the Recharge Theme Engine
    • Connecting the Stripe integration
    • Configuring Cancel Management with Billing
    • Configuring Offer Management
    • Enrichment with Chargebee, Stripe, Recurly
    • Validating Saves against your billing system
    • Slack Integration
    • Using Webhooks with Zapier
    • Salesforce Integration
    • Segment.com Integration
    • Pass Data to Chargebee Retention with Segment Analytics JS snippet

Starter Churn Insights


  • Starter Churn Insights

Retention Best Practices


  • Testing in Chargebee Retention

Security


  • Chargebee Retention Security Overview
  1. Retention
  2. Integrations
  3. Integrations Overview
  4. Pass Data to Chargebee Retention with Segment Analytics JS snippet
Proactively retain, expand, and grow revenue with Chargebee Growth - the next evolution of Chargebee Retention.Built on top of Chargebee Billing, Growth empowers you to design, experiment, and deploy monetization strategies not just at the moment of cancel but across the entire subscriber lifecycle.Go through ourdocumentationto know more.
  1. Retention
  2. Integrations
  3. Integrations Overview
  4. Pass Data to Chargebee Retention with Segment Analytics JS snippet

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 browser when they hit the cancel button. These traits can then be mapped in Field Mapping and used to personalize your Pages or define custom Audiences in Chargebee Retention.

<pre><code><script type="text/javascript" src="https://app.retention.chargebee.com/js/current/brightback.js?compiled=true"></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: Segment.group() ? Segment.group.traits() :{}
      };
    window.Brightback.handleData({
      app_id: "APP_ID", 
      email: email, 
      account: {
        internal_id: userId, 
      },
      custom: {
        segment: segmentData,
        },
    });
  }
  
</script>
</code></pre>

This code snippet will pull back the fields you have under your User Traits and Group Traits within Segment. For more on Segments traits, read Segment's documentation. 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 retention-support@chargebee.com.

Was this article helpful?