gdpr-consent
Version:
GDPR banner to comply with the European cookie law. Inspired by tarteaucitronjs.
40 lines (39 loc) • 1.34 kB
JavaScript
import { addScript } from "../utils/index.js";
export const facebookpixel = ((user) => {
return {
key: "facebookpixel",
type: "analytic",
name: "Facebook Pixel",
uri: "https://www.facebook.com/privacy/policies/cookies/",
needConsent: true,
lazyConsent: false,
cookies: ["datr", "fr", "reg_ext_ref", "reg_fb_gate", "reg_fb_ref", "sb", "wd", "x-src", "_fbp"],
js: function () {
if (window.fbq) {
return;
}
const n = (window.fbq = function () {
if (n.callMethod) {
n.callMethod.apply(n, arguments);
}
else {
n.queue.push(arguments);
}
});
if (!window._fbq) {
window._fbq = n;
}
n.push = n;
n.loaded = !0;
n.version = "2.0";
n.queue = [];
addScript("https://connect.facebook.net/en_US/fbevents.js", { id: "facebook-fbevents" }, function () {
window.fbq("init", user.fbPixelId);
window.fbq("track", "PageView");
if (typeof user.facebookpixelMore === "function") {
user.facebookpixelMore();
}
});
},
};
});