Created
November 6, 2020 18:15
-
-
Save mcnaveen/350bee634b1d1dd4638c9690d9b698f6 to your computer and use it in GitHub Desktop.
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
<center> | |
<div class="fb-messenger-checkbox" origin="" page_id="PAGEID" messenger_app_id="APPID" user_ref="" prechecked="true" allow_login="true" size="large"></div > | |
</center> | |
<script> window.fbMessengerPlugins = window.fbMessengerPlugins || { | |
init: function() { | |
FB.init({ | |
appId: "APPID", | |
xfbml: true, | |
version: "v8.0" | |
}); | |
}, | |
callable: [] | |
}; | |
window.fbMessengerPlugins.callable.push(function() { | |
var ruuid, fbPluginElements = document.querySelectorAll(".fb-messenger-checkbox[page_id='PAGEID']"); | |
if (fbPluginElements) { | |
for (i = 0; i < fbPluginElements.length; i++) { | |
ruuid = 'cf_' + (new Array(16).join().replace(/(.|$)/g, function() { | |
return ((Math.random() * 36) | 0).toString(36)[Math.random() < .5 ? "toString" : "toUpperCase"](); | |
})); | |
fbPluginElements[i].setAttribute('user_ref', ruuid); | |
fbPluginElements[i].setAttribute('origin', window.location.href); | |
window.confirmOptIn = function() { | |
FB.AppEvents.logEvent('MessengerCheckboxUserConfirmation', null, { | |
app_id: "APPID", | |
page_id: "PAGEID", | |
ref: "checkbox", | |
user_ref: ruuid | |
}); | |
}; | |
} | |
} | |
}); | |
window.fbAsyncInit = window.fbAsyncInit || function() { | |
window.fbMessengerPlugins.callable.forEach(function(item) { | |
item(); | |
}); | |
window.fbMessengerPlugins.init(); | |
}; | |
setTimeout(function() { | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) { | |
return; | |
} | |
js = d.createElement(s); | |
js.id = id; | |
js.src = "//connect.facebook.net/en_US/sdk.js"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
}, 0); </script> | |
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
<script> | |
Array.from(document.querySelectorAll("#register")).forEach(function( | |
btn | |
) { | |
btn.addEventListener("click", function() { window.confirmOptIn(); }); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment