Pass Data to Brightback w/ Segment Analytics JS snippet

Brightback can receive your Segment data for enrichment by adding a few lines of code to your Brightback.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 Brightback. 

<script type="text/javascript" src="https://app.brightback.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>

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 Brightback. 

For help configuring your JS snippet to include Segment data, contact support@brightback.com

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us