Event Tracking
Integrate Ad Sentinelle events with your analytics tools.
Available Events
The SDK Ad Sentinelle emits JavaScript events you can listen to:
| Event | Trigger | Data |
|---|---|---|
adwall:init | SDK initialized | sessionId, variant |
adwall:detected | Ad blocker detected | blockerType, device |
adwall:displayed | Wall displayed | variant, mode |
adwall:help_opened | Help opened | - |
adwall:cta_clicked | CTA click | - |
adwall:verification_start | Verification starts | - |
adwall:verification_success | Verification OK | - |
adwall:verification_failed | Verification failed | - |
adwall:converted | Conversion confirmed | variant, timestamp |
adwall:closed | Wall closed (Soft) | reason |
adwall:error | Error occurred | error |
Listen to Events
Basic Syntax
window.addEventListener('adwall:converted', function(event) {
console.log('Conversion!', event.detail);
});
With Async/Await
function waitForEvent(eventName) {
return new Promise(resolve => {
window.addEventListener(eventName, resolve, { once: true });
});
}
// Usage
const conversionEvent = await waitForEvent('adwall:converted');
console.log('User converted:', conversionEvent.detail);
Google Analytics 4 Integration
With gtag.js
// Detect ad blocker
window.addEventListener('adwall:detected', function(e) {
gtag('event', 'adblock_detected', {
event_category: 'Ad Sentinelle',
event_label: e.detail.blockerType || 'unknown',
device_type: e.detail.deviceType
});
});
// Wall displayed
window.addEventListener('adwall:displayed', function(e) {
gtag('event', 'adwall_displayed', {
event_category: 'Ad Sentinelle',
event_label: e.detail.variant
});
});
// Conversion
window.addEventListener('adwall:converted', function(e) {
gtag('event', 'adwall_conversion', {
event_category: 'Ad Sentinelle',
event_label: e.detail.variant,
value: 1
});
});
With Google Tag Manager
Create a custom trigger in GTM:
- Triggers → New → Custom Event
- Event name:
adwall:converted - Create associated GA4 tag
// Push to dataLayer
window.addEventListener('adwall:converted', function(e) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'adwall_conversion',
adwall_variant: e.detail.variant,
adwall_session_id: e.detail.sessionId
});
});
Integration with Other Analytics
Matomo / Piwik
window.addEventListener('adwall:detected', function(e) {
_paq.push(['trackEvent', 'Ad Sentinelle', 'Detected', e.detail.blockerType]);
});
window.addEventListener('adwall:converted', function(e) {
_paq.push(['trackEvent', 'Ad Sentinelle', 'Converted', e.detail.variant]);
_paq.push(['trackGoal', 1]); // Your goal ID
});
Plausible
window.addEventListener('adwall:converted', function(e) {
plausible('Ad Sentinelle Conversion', {
props: {
variant: e.detail.variant
}
});
});
Mixpanel
window.addEventListener('adwall:detected', function(e) {
mixpanel.track('Ad Sentinelle Detected', {
blocker_type: e.detail.blockerType,
device: e.detail.deviceType
});
});
window.addEventListener('adwall:converted', function(e) {
mixpanel.track('Ad Sentinelle Conversion', {
variant: e.detail.variant
});
mixpanel.people.set({
'adwall_converted': true,
'adwall_conversion_date': new Date().toISOString()
});
});
Event Data Structure
event.detail Format
interface AdSentinelleEventDetail {
// Available on all events
sessionId: string;
timestamp: number;
// adwall:detected
blockerType?: 'ublock' | 'adblock' | 'adguard' | 'brave' | 'unknown';
deviceType?: 'desktop' | 'mobile' | 'tablet';
// adwall:displayed, adwall:converted
variant?: 'control' | 'emotional' | 'alternative';
mode?: 'hard' | 'soft' | 'banner';
// adwall:closed
reason?: 'button' | 'overlay' | 'escape';
// adwall:error
error?: string;
}
Server Webhook
Send events to your backend:
window.addEventListener('adwall:converted', function(e) {
fetch('/api/adwall/conversion', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sessionId: e.detail.sessionId,
variant: e.detail.variant,
timestamp: Date.now(),
url: window.location.href,
userAgent: navigator.userAgent
})
});
});
Complete Tracking Script
(function() {
const EVENTS = [
'adwall:init',
'adwall:detected',
'adwall:displayed',
'adwall:help_opened',
'adwall:cta_clicked',
'adwall:verification_start',
'adwall:verification_success',
'adwall:verification_failed',
'adwall:converted',
'adwall:closed',
'adwall:error'
];
EVENTS.forEach(eventName => {
window.addEventListener(eventName, function(e) {
console.log(`[Ad Sentinelle] ${eventName}`, e.detail);
if (typeof gtag !== 'undefined') {
gtag('event', eventName.replace('adwall:', 'adwall_'), {
event_category: 'Ad Sentinelle',
...e.detail
});
}
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: eventName,
...e.detail
});
});
});
})();
Debugging
Enable Debug Mode
window.ADWALL_CONFIG = { debug: true };
Console Monitoring
// Display all Ad Sentinelle events
const originalDispatchEvent = window.dispatchEvent;
window.dispatchEvent = function(event) {
if (event.type.startsWith('adwall:')) {
console.log(`%c[Ad Sentinelle Event] ${event.type}`, 'color: #8b5cf6', event.detail);
}
return originalDispatchEvent.apply(this, arguments);
};
Tip
Test your analytics integration in debug mode before deploying to production.