Last active
February 3, 2021 18:56
-
-
Save rsiddle/d55799b99bbea8616a6cd11040f6745d to your computer and use it in GitHub Desktop.
Hide Retargeting Cookies (Delayed Scripts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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