Table of Contents

Facebook Pixel - Track Events (Embedded)

Pau Sanchez Updated by Pau Sanchez

This process is only suitable for Embedded landbots. If you're landbot is not embedded in your website, check our guide here

Bot is embedded in a site

When your bot is embedded in one of the four different ways available: Fullpage, Popup, Embed or Livechat (with custom domain).

In Landbot 3

You should apply this process when landbot is embedded into your website - using a domain that’s different from “landbot.io”. This process is very useful to track landbot and leads conversions, track events with Facebook Pixel

How the code in your site is going to look like with the snippets in these instructions:

<html>

<head>

<script> !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', '121071555287839'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=121071555287839&ev=PageView&noscript=1" /></noscript>

</head>

<body>

</body>

<script src="https://static.landbot.io/landbot-widget/landbot-widget-1.0.0.js"></script>
<script> var myLandbot = new LandbotLivechat({
index: 'https://landbot.io/u/H-XXXXXX-XXXX/index.html', });
</script>

</html>

What to edit in the Site (container):
  1. Be sure you're using a standard Facebook Pixel Code implementation like this one:
In the code below, please change the 121071555287839 for your Facebook Pixel ID


<script> !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', '121071555287839'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=121071555287839&ev=PageView&noscript=1" /></noscript>

  1. Add your Landbot to your container’s webpage using the snippet provided by the app:


<script src="https://static.landbot.io/landbot-widget/landbot-widget-1.0.0.js"></script>
<script> var myLandbot = new LandbotLivechat({
index: 'https://landbot.io/u/H-XXXXXX-XXXX/index.html', });
</script>

What to edit in your bot (Landbot builder):
  1. In your chatbot builder, add this code to a Code . This is the point in the flow when you want to send the event to Facebook. Replace the parameters with your own values:
window.fbq('track','Lead')

Change the example values with your own values. You can use landbot variable there.

In Landbot 2

Important: Do not use the Facebook Pixel tracking code on the Landbot side (leave the Facebook Pixel ID field blank on Settings > SEO & Tracking) to make sure it doesn’t duplicate visitors.

You should apply this process when landbot is embedded into your website - using a domain that’s different from “landbot.io”. This process is very useful to track landbot and leads conversions, track events with Facebook Pixel

How the code in your site is going to look like with the snippets in these instructions:

<html>

<head>

<script> !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', '121071555287839'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=121071555287839&ev=PageView&noscript=1" /></noscript>

</head>

<body>

</body>

<script src="https://static.landbot.io/landbot-widget/landbot-widget-1.0.0.js"></script>
<script> var myLandbot = new LandbotLivechat({
index: 'https://landbot.io/u/H-222098-Z7UGOMG4SI4TMMVP/index.html', });
</script>


<script>
myLandbot.on('fbLandbot',function(data){ fbq(data.args); });
</script>

</html>

What to edit in the Site (container):
  1. Be sure you're using a standard Google Analytics implementation like this one:
In the code below, please change the 121071555287839 for your Facebook Pixel ID


<script> !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', '121071555287839'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=121071555287839&ev=PageView&noscript=1" /></noscript>

  1. Add your Landbot to your container’s webpage using the snippet provided by the app:

<script src="https://static.landbot.io/landbot-widget/landbot-widget-1.0.0.js"></script>
<script> var myLandbot = new LandbotLivechat({
index: 'https://landbot.io/u/H-222098-Z7UGOMG4SI4TMMVP/index.html', });
</script>
  1. Add this code to the footer of your container’s webpage where landbot will be located (add it after the Landbot snippet of step 1):


<script>
myLandbot.on('fbLandbot',function(data){ fbq(data.args); });
</script>

What to edit in your bot (Landbot builder):
  1. In your chatbot builder, add this code to a Code block after your “thank you block” - the one that goes right after what you consider a conversion, (e.g. Ask a question > Email). This is the point in the flow when you want to send the event to Google Analytics. Replace the parameters with your own values:
Landbot.send('fbLandbot', {args: ['track', 'Lead']});

Change the example values with your own values. You can use landbot variable there.

FAQ & Troubleshooting

How can I check if the tracking is working correctly?

To test that you installed the pixel correctly, install the Chrome Pixel Helper extension (it’s free!) and then visit your site.

How did we do?

Landbot native SEO & Tracking tools

Google Adwords - How to track Google Adwords in Landbot

Contact