Documentation — Segment Integration

Welcome to the Segment integration for the Modern Pricing API! You can use the Segment integration for Modern Pricing to access Modern Pricing API endpoints, which can provide information regarding the visitors to your website and their ability to afford your goods and services.

Getting Started

  1. From your Segment UI’s Destinations page click on “Add Destination”.
  2. Search for “Modern Pricing” within the Destinations Catalog and confirm the Source you’d like to connect to.
  3. Drop in the “Base64 Decoded Key” into your Segment Settings UI which you can find from your Modern Pricing API Credentials page. Note: You must click on the active API Key Value to view the Base64 Decoded Key.


Page calls are the only type of call supported by Modern Pricing. Your Page calls must:

  1. Be sent from a server-side source, not the default Segment analytics.js snippet.
  2. Pass along at least an ip_address in the context object. You may optionally provide the user_agent parameter for more accurate scoring.

  3. Query Parameters
    Parameter Required Description
    ip_address true The ip address of the visitor you want to score.
    user_agent false The software client acting on behalf of the visitor.

The IP Address and User Agent are not automatically collected by Segment’s server-side libraries and you will need to manually grab these fields from the client and pass them to the server.

An example call would look like:
  context: {
    ip_address: request.remote_ip,
    user_agent: request.user_agent
  properties: {
    url: request.original_url,
    path: request.path,
    referrer: request.referrer

Page calls will be sent to Modern Pricing as a pageview. If you haven’t had a chance to review our spec, please take a look to understand what the Page method does.

Optional Best Practices

Modern Pricing recommends the following best practices to reduce unnecessary calls to their API that will count against your monthly usage.

For anonymous visitors:

  • Check that the visitor’s User Agent is not a bot.

if user_agent != bot
  // Send Page call

For logged in visitors:

  • Save the Modern Pricing score on your user model so you ensure a consistent user experience.

# == Schema Information
# Table name: users
# id                      :bigint(8)
# first_name              :string
# last_name               :string
# email                   :string
# modern_pricing_score    :string

Identify Postback

When you integrate Modern Pricing via Segment, Modern Pricing returns a postback Identify call to your source so that you’ll be able to easily pass the score to your downstream destinations.

How does it work?

  1. You send a Page call from your server-source like normal.
  2. Modern Pricing then recognizes your Page call and automatically returns and Identify call with the modern_pricing_score trait.

Segment is then able to send the Modern Pricing score to the other destinations you have connected to your source.