Technical FAQ
Technical questions and answers for developers implementing Biskoui.
How do I check if a specific service has consent?
Use the hasAcceptedService() method to check consent status for any configured service:
// Check consent status
if (biskoui.hasAcceptedService('google_analytics')) {
// Google Analytics is allowed - safe to initialize
gtag('config', 'GA_MEASUREMENT_ID');
}
if (biskoui.hasAcceptedService('youtube')) {
// YouTube embeds are allowed
loadYouTubeVideos();
}
This method returns true if the user has explicitly granted consent for the service, and false if they declined or haven't decided yet. Service keys must match exactly what's configured in your Biskoui dashboard (e.g., google_analytics, facebook_pixel, hotjar).
How should I handle services that need to load immediately when consent is granted?
Use service activation events to respond instantly when users grant consent:
// Listen for specific service activation
window.addEventListener('biskoui:google_analytics_activated', function() {
// This fires immediately when Google Analytics consent is granted
initializeAnalytics();
});
window.addEventListener('biskoui:facebook_pixel_activated', function() {
// This fires when Facebook Pixel consent is granted
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
});
// For existing consent (page reload), check on SDK ready
window.addEventListener('biskoui:ready', function() {
// Check existing consent and initialize if already granted
if (biskoui.hasAcceptedService('google_analytics')) {
initializeAnalytics();
}
});
Events fire both for new consent decisions and existing consent when the page loads, ensuring your services activate correctly in all scenarios.
What's the difference between script blocking and JavaScript events?
Both approaches achieve consent-dependent execution but serve different use cases:
Script Blocking - Use for simple initialization code:
<script type="text/plain" data-biskoui="google_analytics">
// Automatically executes when Google Analytics consent is granted
gtag('config', 'GA_MEASUREMENT_ID');
gtag('event', 'page_view');
</script>
JavaScript Events - Use for complex logic or conditional behavior:
window.addEventListener('biskoui:google_analytics_activated', function() {
// Complex initialization with conditions
if (userIsLoggedIn) {
gtag('config', 'GA_MEASUREMENT_ID', { user_id: currentUserId });
} else {
gtag('config', 'GA_MEASUREMENT_ID');
}
// Track custom events based on page content
if (isProductPage) {
gtag('event', 'view_item', { item_id: productId });
}
});
Script blocking is declarative and automatic, while events give you full programmatic control. You can use both approaches together on the same page.
Why isn't my script being executed when I grant consent?
Common issues and solutions:
1. Check the service key matches exactly:
<!-- ❌ Wrong: Mismatched service key -->
<script type="text/plain" data-biskoui="analytics">
gtag('config', 'GA_ID');
</script>
<!-- ✅ Correct: Must match dashboard configuration -->
<script type="text/plain" data-biskoui="google_analytics">
gtag('config', 'GA_ID');
</script>
2. Verify the script type attribute:
<!-- ❌ Wrong: Will execute immediately -->
<script data-biskoui="google_analytics">
gtag('config', 'GA_ID');
</script>
<!-- ✅ Correct: Blocked until consent -->
<script type="text/plain" data-biskoui="google_analytics">
gtag('config', 'GA_ID');
</script>