How to fire FB pixel events when visitors click-through on your landers
If you use Facebook as a traffic source, you likely want to use the Facebook pixel to track user events such as landing page visits, click-throughs and conversions.
For conversions, you must be able to run client-side code, such as JavaScript or an iframe, on your offer conversion pages. If the offer owner or affiliate network does not allow this, the pixel cannot fire on a purchase, because the code must run in the user’s browser. In that case, send conversions server-side with the Facebook Conversions API.
Below are three ways to fire Facebook pixel events when users click through on your landing pages. A click-through is a moderate-value event that shows user intent, so it is useful for your Facebook reporting and for custom audiences.
Note: read Basic redirection scripts and approaches first to get familiar with JavaScript redirection for outgoing links.
FunnelFlux action links
Section titled “FunnelFlux action links”The examples on this page send visitors to FunnelFlux action links.
An action link is your tracking domain with a flux_action parameter holding the action number, for example:
https://mydomain.com/?flux_action=1Use the action links FunnelFlux generates for your funnel, and replace mydomain.com with your tracking domain.
Option 1: Simple on-page JavaScript events
Section titled “Option 1: Simple on-page JavaScript events”If you can edit your lander and are comfortable making basic code changes, this is the best method.
You create a function that fires a Facebook event, then add an onclick attribute to any links (<a> elements) where you want it to fire.
The advantage is that you avoid an extra redirect. It also allows more dynamic event processing in advanced situations.
Step 1: Add the Facebook JavaScript to your page
Section titled “Step 1: Add the Facebook JavaScript to your page”You need Facebook’s pixel code on your page.
Paste it in the <head> region, then add a function for firing events on click:
<!-- Facebook Pixel Code --><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', 'PIXEL_ID'); fbq('track', 'PageView');
function fbLeadEvent() { fbq('track', 'Lead'); }</script><!-- End Facebook Pixel Code -->Replace PIXEL_ID with your pixel ID.
The extra part is the fbLeadEvent function, which sends a standard “Lead” event to Facebook.
Step 2: Call the function on click
Section titled “Step 2: Call the function on click”Add onclick="fbLeadEvent();" to any element where a click should fire the event, for example:
<a href="https://mydomain.com/?flux_action=1" onclick="fbLeadEvent();">Link text here</a>You can add this onclick attribute to almost any element.
Create more functions to fire other standard events, such as AddToCart or CompleteRegistration.
See Meta’s standard events reference for the full list.
The browser leaves the page as soon as the link opens, so the event can occasionally be lost. If you need a delay before the redirect, use option 3.
Option 2: FunnelFlux’s JavaScript nodes
Section titled “Option 2: FunnelFlux’s JavaScript nodes”Use a JavaScript node in the funnel builder to tag visitors as they pass through to your offer. To add one, right-click the canvas and choose Advanced > Add JS Code:
![]()
In the JavaScript node, place your Facebook pixel code and edit it to fire the event you want. Then set Delay before redirect (milliseconds); the default is 1000. Facebook’s JavaScript usually runs quickly, so 500 ms should be enough:
![]()
This example uses the standard AddToCart event to represent a lander click-through, since it is the closest standard event. You can also use custom events.
Option 3: Use JavaScript to control link redirection
Section titled “Option 3: Use JavaScript to control link redirection”This option uses JavaScript to listen for clicks on links, fire events, then redirect.
JavaScript, not the <a> elements, controls navigation.
Step 1: Replace outgoing CTA links
Section titled “Step 1: Replace outgoing CTA links”Take the links that normally go to FunnelFlux actions and rewrite them.
For example, take:
<a href="https://mydomain.com/?flux_action=1">My CTA</a>and replace it with:
<a href="javascript:void(0);" class="CTA1">My CTA</a>Do this for all outgoing FunnelFlux action links. If you use multiple actions, name the classes CTA1, CTA2, and so on.
You can use IDs instead, but classes suit the common case of several CTA links that should all behave the same way.
Step 2: Add JavaScript to control click events
Section titled “Step 2: Add JavaScript to control click events”The script takes over outgoing clicks and does the following:
- Fires the Facebook pixel event.
- Appends an image pixel for tracking events with third parties.
- Waits to give those events time to go through.
- Redirects the browser to your FunnelFlux action link.
Place the following code in the footer of your lander, before </body>.
Put your Facebook pixel code earlier in the page, otherwise fbq('track', ...) calls will not work.
This is an example configuration; adapt it to your situation.
The Chrome extension “Meta Pixel Helper” lets you check that events fire.
<!-- footer include --><script> // Fire events and redirect on CTA1 click function CTA1_click() { fbq('track', 'Lead');
var img = document.createElement('img'); img.src = 'URL_HERE'; document.body.appendChild(img);
setTimeout(function () { window.location.href = 'https://mydomain.com/?flux_action=1'; }, 500); }
var cta1Links = document.getElementsByClassName('CTA1'); for (var i = 0; i < cta1Links.length; i++) { cta1Links[i].addEventListener('click', CTA1_click); } // End of CTA events</script><!-- end footer include -->This code fires a Lead event on click-through, appends an image pixel, and redirects to your action 1 link after 500 ms.
Replace URL_HERE with your third-party pixel URL, or remove those three lines if you do not need one.
For more advanced tracking, fill event parameters from URL parameters and handle CTA1, CTA2, and so on. Here is a fuller example:
<!-- footer include --><script> function getURLParameter(name) { return new URLSearchParams(window.location.search).get(name) || ''; }
function appendImagePixel(url) { var img = document.createElement('img'); img.src = url; document.body.appendChild(img); }
function bindCTA(className, onClick) { var links = document.getElementsByClassName(className); for (var i = 0; i < links.length; i++) { links[i].addEventListener('click', onClick); } }
// Fire events and redirect on CTA1 click bindCTA('CTA1', function () { fbq('track', 'Lead', { content_name: getURLParameter('some_url_param'), content_category: getURLParameter('some_other_url_param'), }); appendImagePixel('URL_HERE'); setTimeout(function () { window.location.href = 'https://mydomain.com/?flux_action=1'; }, 500); });
// Fire events and redirect on CTA2 click bindCTA('CTA2', function () { fbq('track', 'CompleteRegistration', { content_name: getURLParameter('some_url_param'), content_category: getURLParameter('some_other_url_param'), }); appendImagePixel('SOME_OTHER_URL_HERE'); setTimeout(function () { window.location.href = 'https://mydomain.com/?flux_action=2'; }, 500); }); // End of CTA events</script><!-- end footer include -->Test your code and configuration before using it in production.

