- 02 Sep 2022
- 1 Minute to read
- DarkLight
Facebook Pixel
- Updated on 02 Sep 2022
- 1 Minute to read
- DarkLight
What Is Facebook Pixel?
Facebook Pixel is a piece of code that you add to your Members Portal's template to help you measure the effectiveness of your ad campaigns by tracking the actions people take on the portal.
Facebook Pixel can help you make sure your ads are shown to the right customers, drive more sales, or even accurately measure the results of your ads.
Connecting Facebook Pixel to Your Members Portal
Connecting your Members Portal to your Facebook Pixel is a simple two-step process.
Step 1. Creating a Facebook Pixel For Your Members Portal
You first need to create your Facebook Pixel. You can find full instructions on Facebook's Business Help Center.
You also need to copy and save your Pixel ID before moving to the next step. You can find your Pixel ID under it's name or by clicking on the Settings tab in your Events Manager.
Step 2. Adding Your Pixel ID & Code Snippet to the head.js and app.js Files
Now that you have your Pixel set up and its ID handy, you need to add a code snippet to your head.js and app.js files on the Admin Panel.
Log in to dashboard.nexudus.com if you aren't already.
Click Settings > Web template editor.
Click Built-in files > head.js.
Copy the following code snippet and paste it at the end of the head.js file.
[
{
"type": "script",
"name": "fb-pixel",
"content": "!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', 'YOUR_FACEBOOK_PIXEL_ACCOUNT');fbq('track', 'PageView');"
}
]
- Replace YOUR_FACEBOOK_PIXEL_ACCOUNT with your Pixel ID, making sure you don't remove the simple quotation marks.
Click the Save button.
You now also need to add a code snippet to your app.js template file.
Click on app.js.
Scroll down to the bottom of the page and paste add the following code snippet.
function routeChangeStartHandler(url) {
if(!window.pixelAdded){
!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', '177461420223136');;
fbq('track', 'PageView')
window.pixelAdded = true;
}
else {
fbq('track', 'PageView')
}
}
var componentDidMount = function(componentName) {
if(!window.handlerSet){
next.router.events.on('routeChangeComplete', routeChangeStartHandler)
window.handlerSet = true;
}
routeChangeStartHandler(next.router.route);
}
Click the Save button.
All set! You've connected your Facebook Pixel to your Members Portal.
You can test your connection by following the instructions available on the Facebook Business Help Center.