Created
May 30, 2012 09:07
-
-
Save DimitarChristoff/2834807 to your computer and use it in GitHub Desktop.
pixel tracking ftw
This file contains 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
;(function() { | |
var lazyLoadScript = function(url) { | |
// make sure the script being loaded does not do document.write and can be deferred. | |
var ns = document.createElement('script'), | |
s = document.getElementsByTagName('script')[0]; | |
ns.type = 'text/javascript'; | |
ns.async = true; | |
ns.src = url; | |
s.parentNode.insertBefore(ns, s); | |
}, makePixelRequest(url, pixelType) { | |
// ensure SSL is kept/enforced. | |
document.location.protocol == 'https:' && (url = url.replace('http:', 'https:')); | |
if (pixelType == 'javascript') { | |
lazyLoadScript(url); | |
} else { | |
// non-blocking get request | |
setTimeout(10, function() { | |
var img = new Image(); | |
img.src = url; | |
}); | |
} | |
}; | |
makePixelRequest('http://cm.g.doubleclick.net/pixel?google_nid=invitemedia&google_cm', 'image'); | |
makePixelRequest('http://ad.yieldmanager.com/pixel?id=1836922&id=1836923&t=2', 'image'); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment