Last active
June 27, 2016 18:12
-
-
Save jimmysawczuk/fa3e71fb150d0df2c12bc9c317aa36d6 to your computer and use it in GitHub Desktop.
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
!function(win, doc, element, url, queue, new_script, invoking_script) | |
{ | |
// this function is going to attempt to define a queue function we can use to track events. if | |
// we've defined it once, we're done. | |
if (win.fbq) return; | |
// callMethod is defined once we load the Facebook library, but if we get an fbq call before then we'll | |
// all the arguments onto a queue to be dealt with later. | |
queue = win.fbq = function() | |
{ | |
queue.callMethod? queue.callMethod.apply(queue, arguments) : queue.queue.push(arguments) | |
}; | |
// define _fbq in parallel with fbq, if it's not defined already. | |
if (!win._fbq) win._fbq = queue; | |
// we're now reshaping the queue function as an object with some helper parameters. | |
queue.push = queue; | |
queue.loaded = true; | |
queue.version = '2.0'; | |
queue.queue = []; | |
// inject the fbevents.js script from Facebook | |
new_script = doc.createElement(element); | |
new_script.async = true; | |
new_script.src = url; | |
invoking_script = doc.getElementsByTagName(element)[0]; | |
invoking_script.parentNode.insertBefore(new_script, invoking_script); | |
}(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js'); | |
// set up the library | |
fbq('init', '<ID>'); | |
// track something | |
fbq('track', "PageView"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment