Untitled

 avatar
unknown
plain_text
a month ago
1.0 kB
20
Indexable
<script>

function isLikelyBot() {

const ua = navigator.userAgent.toLowerCase();

const botPatterns = [

'bot',

'crawler',

'spider',

'headless',

'curl',

'wget',

'python',

'scrapy',

'phantom',

'selenium',

'facebookexternalhit',

'monitoring',

'preview'

];

return botPatterns.some(pattern => ua.includes(pattern));

}

function fireViewContent() {

// Block obvious bots

if (isLikelyBot()) {

console.log('Bot detected - Pixel blocked');

return;

}

// Require user interaction first

let interacted = false;

const markInteraction = () => {

interacted = true;

document.removeEventListener('mousemove', markInteraction);

document.removeEventListener('touchstart', markInteraction);

document.removeEventListener('scroll', markInteraction);

fbq('track', 'ViewContent');

};

document.addEventListener('mousemove', markInteraction, { once: true });

document.addEventListener('touchstart', markInteraction, { once: true });

document.addEventListener('scroll', markInteraction, { once: true });

}

fireViewContent();

</script>
Editor is loading...
Leave a Comment