["<script><!-- Facebook Pixel Code -->\n    \n                \n          !function(f, b, e, v, n, t, s) {\n          if (f.fbq) return;\n          n = f.fbq = function() {\n            n.callMethod ?\n              n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n          };\n          if (!f._fbq) f._fbq = n;\n          n.push = n;\n          n.loaded = !0;\n          n.version = \"2.0\";\n          n.queue = [];\n          t = b.createElement(e);\n          t.async = !0;\n          t.src = v;\n          s = b.getElementsByTagName(e)[0];\n          s.parentNode.insertBefore(t, s);\n        }(window, document, \"script\",\n          \"https://connect.facebook.net/en_US/fbevents.js\");\n\n        fbq(\"init\", '964963288819489');\n\n        \n                                let eventTime = Date.now();\n            let event = 'PageView';\n            let eventID = 'page.PageView.46175.' + \"tx_\" + eventTime;\n        \n                    let post = {\n              domain: 'artfullearning.be',\n              conversion_type: 'PageView',\n              url: window.location.href,\n              event_id: eventID,\n              event_time: eventTime,\n            };\n\n            const queryString = window.location.search;\n            const urlParams = new URLSearchParams(queryString);\n\n            if (urlParams.get(\"pagese\")) {\n              post.email = urlParams.get(\"pagese\");\n            }\n\n            if (urlParams.get(\"pagesf\")) {\n              post.first_name = urlParams.get(\"pagesf\");\n            }\n\n            if (urlParams.get(\"pagesl\")) {\n              post.last_name = urlParams.get(\"pagesl\");\n            }\n\n            const url = 'https://artfullearning.be/client/facebook-conversion/events';\n            let xhr = new XMLHttpRequest();\n            xhr.open(\"POST\", url, true);\n            xhr.setRequestHeader(\"Content-type\", \"application/json; charset=UTF-8\");\n            xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n            xhr.send(JSON.stringify(post));\n        \n                    if (event) {\n                fbq(\"track\", 'PageView');\n            }\n                \n        <!-- End Facebook Pixel Code -->\n</script>",{"name":"fb","location":"head","consentType":"statistical","content":"<script><!-- Facebook Pixel Code -->\n    \n                \n          !function(f, b, e, v, n, t, s) {\n          if (f.fbq) return;\n          n = f.fbq = function() {\n            n.callMethod ?\n              n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n          };\n          if (!f._fbq) f._fbq = n;\n          n.push = n;\n          n.loaded = !0;\n          n.version = \"2.0\";\n          n.queue = [];\n          t = b.createElement(e);\n          t.async = !0;\n          t.src = v;\n          s = b.getElementsByTagName(e)[0];\n          s.parentNode.insertBefore(t, s);\n        }(window, document, \"script\",\n          \"https://connect.facebook.net/en_US/fbevents.js\");\n\n        fbq(\"init\", '964963288819489');\n\n        \n                                let eventTime = Date.now();\n            let event = 'PageView';\n            let eventID = 'page.PageView.46175.' + \"tx_\" + eventTime;\n        \n                    let post = {\n              domain: 'artfullearning.be',\n              conversion_type: 'PageView',\n              url: window.location.href,\n              event_id: eventID,\n              event_time: eventTime,\n            };\n\n            const queryString = window.location.search;\n            const urlParams = new URLSearchParams(queryString);\n\n            if (urlParams.get(\"pagese\")) {\n              post.email = urlParams.get(\"pagese\");\n            }\n\n            if (urlParams.get(\"pagesf\")) {\n              post.first_name = urlParams.get(\"pagesf\");\n            }\n\n            if (urlParams.get(\"pagesl\")) {\n              post.last_name = urlParams.get(\"pagesl\");\n            }\n\n            const url = 'https://artfullearning.be/client/facebook-conversion/events';\n            let xhr = new XMLHttpRequest();\n            xhr.open(\"POST\", url, true);\n            xhr.setRequestHeader(\"Content-type\", \"application/json; charset=UTF-8\");\n            xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n            xhr.send(JSON.stringify(post));\n        \n                    if (event) {\n                fbq(\"track\", 'PageView');\n            }\n                \n        <!-- End Facebook Pixel Code -->\n</script>","attributes":null}]