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
- The plugin listens for the
sesamyJsAuthenticatedevent - When a user authenticates, it extracts the authentication source from
event.detail.appState.source - It sends a custom Facebook Pixel event:
login-{source}
Events Tracked
| Event Name | When Triggered | Description |
|---|---|---|
login-email | Email login | User logged in with email/password |
login-google | Google OAuth | User logged in with Google |
login-facebook | Facebook OAuth | User logged in with Facebook |
login-apple | Apple OAuth | User 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:
- Create custom audiences based on login events
- Measure conversion rates by login method
- Optimize ads for specific authentication sources
- Track the customer journey from ad click to login
Creating Custom Conversions
- Go to Facebook Events Manager
- Click "Custom Conversions"
- Create a conversion based on the custom event (e.g.,
login-email) - 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: undefinedUse 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