Skip to content

Amplitude Plugin ​

The Amplitude plugin automatically identifies users in Amplitude analytics when they authenticate with Sesamy.

Overview ​

This plugin integrates Sesamy authentication with Amplitude analytics, allowing you to track user behavior and entitlements in your analytics platform.

Features ​

  • Automatic User Identification: Identifies users in Amplitude when they log in
  • Entitlement Tracking: Sets user properties based on their bundles/subscriptions
  • Company Information: Includes company data when available

Requirements ​

You must have the Amplitude SDK loaded on your page:

html
<script src="https://cdn.amplitude.com/libs/analytics-browser-2.0.0-min.js.gz"></script>
<script>
  window.amplitude = window.amplitude || { getInstance: function() { return this; } };
</script>

How It Works ​

  1. The plugin listens for the sesamyJsReady event
  2. When a user authenticates, it retrieves their user data
  3. It sets the Amplitude user ID and properties:
    • User ID: Sesamy user ID
    • Company: User's company (if available)
    • Bundles: Array of bundle titles the user has access to

User Properties Set ​

PropertyTypeDescription
userIdstringSesamy user ID
companystringUser's company name
bundlesstring[]Array of bundle titles user has access to

Example Usage ​

Once configured, the plugin runs automatically:

javascript
// No additional code needed - plugin runs automatically
window.addEventListener('sesamyJsReady', () => {
  console.log('Sesamy and Amplitude integration active');
});

Tracking User Behavior ​

With users identified in Amplitude, you can:

  • Track content consumption by subscription type
  • Analyze conversion funnels by bundle
  • Segment users by entitlements
  • Monitor churn and retention by subscription tier

Example Analytics Query ​

javascript
// In Amplitude, you can now segment by bundles
// Example: Users with "Premium Bundle" who viewed article
{
  event: "page_view",
  filters: [
    { property: "bundles", operator: "contains", value: "Premium Bundle" }
  ]
}

Debugging ​

Check the browser console for Amplitude identification logs:

javascript
// Console output when working correctly
// "Identifying user for Amplitude"
// Amplitude identify call with user properties

Released under the MIT License.