Skip to content

Meta Tracking Plugin

The Meta Tracking plugin tracks authentication events to Facebook Pixel, allowing you to measure the effectiveness of different login sources.

Overview

This plugin sends custom events to Facebook Pixel when users authenticate through Sesamy, including information about the authentication source (e.g., email, social login).

Features

  • Authentication Tracking: Tracks when users log in
  • Source Attribution: Records the login method used
  • Custom Events: Sends Facebook Pixel custom events

Requirements

You must have Facebook Pixel installed on your page:

html
<!-- Facebook Pixel Code -->
<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', 'YOUR_PIXEL_ID');
  fbq('track', 'PageView');
</script>

How It Works

  1. The plugin listens for the sesamyJsAuthenticated event
  2. When a user authenticates, it extracts the authentication source from event.detail.appState.source
  3. It sends a custom Facebook Pixel event: login-{source}

Events Tracked

Event NameWhen TriggeredDescription
login-emailEmail loginUser logged in with email/password
login-googleGoogle OAuthUser logged in with Google
login-facebookFacebook OAuthUser logged in with Facebook
login-appleApple OAuthUser logged in with Apple

Example Usage

Once configured, the plugin runs automatically:

javascript
// No additional code needed - plugin runs automatically
window.addEventListener('sesamyJsAuthenticated', (event) => {
  console.log('User authenticated:', event.detail.appState.source);
  // Meta tracking plugin will send Facebook Pixel event
});

Facebook Ads Manager

In Facebook Ads Manager, you can:

  1. Create custom audiences based on login events
  2. Measure conversion rates by login method
  3. Optimize ads for specific authentication sources
  4. Track the customer journey from ad click to login

Creating Custom Conversions

  1. Go to Facebook Events Manager
  2. Click "Custom Conversions"
  3. Create a conversion based on the custom event (e.g., login-email)
  4. Use in your ad campaigns

Example Conversion Setup

javascript
// In Facebook Events Manager, create a custom conversion:
{
  "name": "Email Login Conversion",
  "event": "login-email",
  "description": "Users who logged in via email"
}

Debugging

The plugin includes console logging for debugging:

javascript
// Console output when working correctly
// [meta-tracking] sesamyJsAuthenticated event triggered
// [meta-tracking] event.detail: {...}
// [meta-tracking] appState: {...}
// [meta-tracking] Meta fbq trackCustom called with event: login-email

// If conditions not met
// [meta-tracking] Conditions not met - fbq: true, detail: true, appState: true, source: undefined

Use Cases

Attribution

Track which login methods drive the most conversions:

  • Email login vs social login performance
  • Compare user behavior by authentication source

Retargeting

Create audiences based on authentication method:

  • Users who logged in with email (may need password reset help)
  • Users who logged in with social (prefer seamless experiences)

Optimization

Optimize your login flow:

  • A/B test different login button placements
  • Measure impact of adding/removing login options
  • Track login success rates

Released under the MIT License.