Skip to content

Instantly share code, notes, and snippets.

@romainbessugesmeusy
Created July 30, 2019 12:37
Show Gist options
  • Save romainbessugesmeusy/6d88dda61cb1623b0706da6fffe1ebd5 to your computer and use it in GitHub Desktop.
Save romainbessugesmeusy/6d88dda61cb1623b0706da6fffe1ebd5 to your computer and use it in GitHub Desktop.
function launchFB(){
!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','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '159702201342042');
fbq('set','agent','tmgoogletagmanager', '159702201342042');
fbq('track', "PageView");
}
function launchGoogleAnalytics(){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-00000000-1', 'auto');
ga('send', 'pageview');
}
void 0 === window._axcb && (window._axcb = []);
window._axcb.push(function(axeptio) {
axeptio.on("cookies:complete", function(choices) {
if(choices.facebook_pixel) {
launchFB();
}
if(choices.google_analytics) {
loadGoogleAnalytics();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment