Facebook Pixel

Add a Facebook pixel to your site.

Niall Diamond avatar
Written by Niall Diamond
Updated over a week ago

Let's learn how to setup a Facebook Pixel on our site. If you haven't already, you will need to setup a Facebook Business account. Checkout the details at https://business.facebook.com/

Once you have the business account you can move on to setting up the Pixel.

Advanced Monitoring script

πŸ‘ Important: Make sure to add your Pixel ID into the script before you publish the code.

<script>
// We are in the header so can't use bodyclasses to determine whether we are logged in or not
if (EvoXLayer().user.user_id !== null) {
let name = () => {
let name = EvoXLayer().user.name;
return name.split(" ");
}
let phone = () => {
if (EvoXLayer().user.cell == '') {
return EvoXLayer().user.phone
} else {
return EvoXLayer().user.cell
}
}
// fb push event
fbq('init', 'replace_this_with_your_px_id', {
em: EvoXLayer().user.email, //Values will be hashed automatically by the pixel using SHA-256
fn: name()[0],
ln: name().slice(1).join(" "),
ph: phone(),
external_id: EvoXLayer().user.user_id
});
}
</script>


That's it, have a great day πŸŽ‰

Did this answer your question?