Santebienetre / script.js
Djackis's picture
Optimise et met a jour avec les nouvelles donnes
fd2970b verified
Raw History Blame Contribute Delete
1.85 kB
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Facebook SDK integration
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
autoLogAppEvents : true,
xfbml : true,
version : 'v12.0'
});
};
// Load Facebook SDK
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/fr_FR/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Product tracking
document.querySelectorAll('[data-product]').forEach(btn => {
btn.addEventListener('click', function() {
const productName = this.getAttribute('data-product');
gtag('event', 'product_click', {
'product_name': productName,
'currency': 'XOF',
'value': this.getAttribute('data-price')
});
});
});
// WhatsApp CTA tracking
document.querySelectorAll('.whatsapp-cta').forEach(btn => {
btn.addEventListener('click', function() {
gtag('event', 'whatsapp_click', {
'event_category': 'CTA',
'event_label': this.getAttribute('data-cta-type')
});
});
});
// Facebook pixel tracking
fbq('track', 'PageView');
// Form submission handling
document.getElementById('contactForm')?.addEventListener('submit', function(e) {
e.preventDefault();
// Handle form submission here
alert('Merci pour votre message! Nous vous contacterons bientôt.');
this.reset();
});