Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hide Retargeting Cookies (Delayed Scripts)
/*
Description
Using the window.setTimeout function will allow you to hide retargeting cookies and execute them after 45 seconds.
This helps provide higher quality leads/audience. The example below shows Facebook's pixel tracker.
It could be used for other pixel tracking services too.
Case Study @ http://imscalable.com/blog/case-study-retargeting-done-wrong/
*/
// Facebook Code
!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','//connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID_HERE');
fbq('track', 'PageView');
// 45 Second Delay Code (45,000 milliseconds)
window.setTimeout(function() {
fbq('track', 'Lead');
// Note: Add other pixel triggers here.
}, 45000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.