Documentation
Documentation
Documentation
  • Documentation
  • Products
    • Fanplayr Targeting Portal
    • Fanplayr 360
    • PrivacyID
    • SiteSpeed
  • Features
    • Merchandising
    • Security
    • SMS
    • Web Push Notifications
      • Direct Integration Guide
      • Popup Integration Guide
      • Imaging Sizing Guide
    • Data Residency
  • Fanplayr Targeting
    • E-Commerce Integrations
      • Fanplayr Tracking for GA4 eCommerce
      • BigCommerce
      • CommerceV3
      • Magento 1
        • Getting Started
        • Configuration
      • Magento 2
      • Miva Merchant
      • PrestaShop
      • Salesforce Commerce Cloud
      • Shopify
      • Volusion
      • VTEX
      • VTEX IO
    • Custom Integration
      • Page tracking
        • Apply to cart
        • Session offers
      • Order tracking
      • Data types
        • CartAction
        • Product
      • Data Layer API
      • Enhanced user identification
        • Manual Integration
      • Segmentation as a service
      • Lazy loading
      • Page caching
      • Tag managers
      • Single page apps
      • Custom data for verticals
        • Travel
      • User Consent for Data
    • Pixel Integration
    • ESP Integrations
    • Link Decoration
    • User Management
      • User Identity
      • User Properties
  • Other
    • CSP & Domains
Powered by GitBook
On this page
  • Callback Template
  • Example: Third-party chat widget

Was this helpful?

  1. Fanplayr Targeting
  2. Custom Integration

Segmentation as a service

A JavaScript API for reacting to segments activated by user behaviors.

PreviousManual IntegrationNextLazy loading

Last updated 5 years ago

Was this helpful?

Fanplayr's Segmentation as a Service is a JavaScript API that emits events with information about segments your users fall into. You can listen to these events to implement custom actions when users fall into specific segments.

This is used in addition to the .

Callback Template

The following snippet is used to listen to segmentation as a service events after Fanplayr tracks each page.

<!-- Before user tracking snippet -->
<script>
window.fanplayr_api = [{
  "_type": "onPageView",
  "callback": function (event) {
    // Called after Fanplayr tracks each page view.
    // `event.segments` is an array of any segment tags the user fell into for the tracked page.
  }
}];
</script>

Example: Third-party chat widget

This mechanism could be used to implement custom logic that opens a third-party chat service when users fall into predefined segments.

<!-- Before user tracking snippet -->
<script>
window.fanplayr_api = [{
  "_type": "onPageView",
  "callback": function (event) {
    if (event.segments.indexOf('High-Value-Customer') !== -1) {
      olark('api.chat.sendMessageToVisitor', {
        body: "Questions? We'd love to chat."
      });
    }
  }
}];
</script>
standard Fanplayr integration