Skip to content

Instantly share code, notes, and snippets.

@haqHUB
Forked from rsiddle/delayed-retargeting.js
Created August 20, 2017 13:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haqHUB/7cb2a5c0ed654b23a0651e1426e78b39 to your computer and use it in GitHub Desktop.
Save haqHUB/7cb2a5c0ed654b23a0651e1426e78b39 to your computer and use it in GitHub Desktop.
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);
@areeb1501
Copy link

How do I add this tracking code to other remarketing platforms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment