The dynamic Facebook pixel should be used when we want to set up the technique once and drive traffic with different pixels, passing their id in the URL parameters. In this article, we will look at step-by-step setup, forwarding a pixel to the thank you page and sending events for more accurate advertising optimization.
- usingtrackerKeitaro
- usingfree clo from yours truly
- without using anything, from scratch
To check the results, we need an extension for Google Chrome —Meta Pixel Helper, install it, guys, and let’s get started!
Let’s understand the logic of actions
First, let’s go through our entire funnel and see how the pixel participates in it:
- In the link that we will be pushing into the Facebook ad, we need to add a certain parameter with the pixel ID as the value so that it looks something like this:
https://mydomain.com?px=12345678
You can choose absolutely any name for the parameter; for this article I will use the namepx. - At the same time, I personally recommend putting this parameter not in the link itself, but in a special field in the ad —«URL Parameters». This way you will slightly protect yourself fromsolder-services that cannot obtain the value of this field.
skrinshot-23-05-2023-140831.png605×605px469skrinshot-23-05-2023-141023
- After the user follows our link and gets to the site, we need somewheresave the pixel identifier (id) from the link. This is usually done inside the application form or in cookies. Let’s consider both options.
If we save the pixel id in the form, then:
- When a user submits a request, the pixel id is sent along with other form fields to the lead processing script. The lead is sent to affiliate network and the “Thank you” page is shown. In the first case, the “Thank you” page is displayed as a redirect, then a parameter with a pixel identifier is added to the redirect link. In the second case, “Thank you” is displayed directly at the address of the lead sending script.
- The “Thank you” page pulls out the required parameter and inserts its value into the tag with the “short” Facebook pixel. The pixel sends a Lead event to Facebook.
If we save the pixel id in a cookie, then:
- The user leaves a request, the Thank You page is shown (in any way)
- The “Thank you” page pulls the pixel id from the cookie and substitutes its value into the tag with the “short” Facebook pixel. The pixel sends a Lead event to Facebook.
NOTE: If you want to pass the pixel through cookies, you MUST use the SAME DOMAIN for the “Thank You” page as your link in the Facebook ad. Otherwise, you will not be able to get the saved pixel id from the cookie.
This is the whole funnel, now let’s look at it in detail using examples.
Forwarding a pixel usingtrackerKeitaro
Settingstracker
First of all, we need to reserve any of the availabletrackermarks for our pixel. To do this, we go to Sources and create (or edit if you created it before) source from Facebook template.

Scroll down Parameters and see that Sub Id 6 already contains a parameter for the pixel. Change its name in the middle column from pixel to px:

Now, when users come to us whose link sayspx=1234443234, pixel id will be stored in 6th labeltracker, and we can use the name we setpxas a macro{px}to get the pixel id value.
Setting up landing pagea
In this case, I will call the landing page the site,which has an application form. In Keitaro’s terms, this is called an “Offer,” but in fact, it doesn’t matter where you put your site, in “Landing Pages” or in “Offers,” the principle of pushing a pixel will be the same.
Let’s look at 2 ways to insert a pixel, through cookies and through a form.
Passing through cookies
We need to save our pixel in a cookie, which we will call exactly the same as the label was called, i.e.px. I suggest doing this using Javascript; in general, you can do it in PHP, but it will be easier. Open our landing page to edit the code and immediately after the tag<body>insert the following code:
<script>document.addEventListener("DOMContentLoaded", function() {
const pxValue = '{px}';
if (!pxValue) return;
const date = new Date();
date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = 'px=' + pxValue + ';' + expires + ';path=/';
});
</script>
That’s it, our pixel is saved (for this, if you noticed, we used Keitaro’s {px} macro), go to«Thank you» page setup step.
Throwing through the form
First, we need to open the index.html or index.php code of our landing page in Keitaro’s built-in editor. Next we look for all the tagsformwho have registeredaction.

In each such form we need to add a hidden field in which to enter the id of the pixel from the px tag saved in Keitaro. To avoid confusion, we call the field the same as the label:<input type="hidden" name="px" value="{px}"/>
Here we are using a macro{px}Keitaro to get from the saved 6th label the pixel id value that is already stored there.
That’s it, now, when the user sends his data to the lead sending script, a pixel will also be included in the script!
P.S. Be sure to check that the form has a submit method specifiedmethod="POST".
Setting up a lead sending script
This point is applicable ONLY if you decide to pass the pixel through the form. If you use cookies, please go straight topage setup Thank you.
First, we find our PHP file for sending leads: it is usually calledorder.php, you can see exactly how it is named in the previous step, when we edited the form: it is registered in the attributeactionat the tagform. Open the file for editing in any text editor (preferably with code highlighting, like Notepad++).
Our task is to understand how traffic flows from the script for sending leads to the Thank you page. There are 2 options:
- After sending the data to affiliate network, the script shows the Thank you page immediately, at its address — this is called “include”.
- The lead sending file redirects the user to the Thank you page, and the address changes accordingly.
If you cannot determine from the code how Thank you is connected in your case, then simply leave a test lead and look at the address bar in the browser. If at the end of the line you see the name of the lead sending file, then you have an include method, if you see something like success.html, then you have a redirect.
Priver: this is what the lead submission file looks like from affiliate network Shakes, where include is used to show Thanks:

If we see that the connection is made through include, then with the lead sending filenothing needs to be done, Let’s move on to the setup immediately Thank you.
Example: this is what the lead submission file looks like from affiliate network Lemonad, where a redirect is used to display Thank you:

Note: you can understand that a redirect is being used by searching for the word in the code Location:
When using a redirect, we have to get a little tricky: we need to add the identifier of our pixel to the redirect address. As always, we will use a parameter namedpx.
We also need to determine whether any other URL parameters are used when redirecting to Thank You. If yes, then add our pixel id to the end of these parameters via an ampersand (&). If there are no other parameters, then through a question mark. This is what it would look like for the above example:
//Option when there are other URL parameters
header('Location: '.$urlSuccess."&px=".$_POST['px']);
//Option when there are NO other URL parameters
header('Location: '.$urlSuccess."?px=".$_POST['px']);
After you have added a pixel to the redirect address,follow this link to set up the page Thank you.
Setting up the Thank You page
Here we look at 3 options: getting the pixel id from a cookie + 2 options, when we pass the pixel through the form and Thank you is connected either through include or through a redirect.
From cookies
So, the moment has come when we willshow our pixel and send the Lead event. To do this, we use the following Javascript code, which we insert immediately after the tag<body>to Thank you:
<script>
document.addEventListener("DOMContentLoaded", function() {
const cookieRegex = /px=([^;]+)/;
const pxCookieMatch = document.cookie.match(cookieRegex);
let pxValue = pxCookieMatch[1];
const imgElement = document.createElement("img");
imgElement.setAttribute("height", "1");
imgElement.setAttribute("width", "1");
imgElement.setAttribute("src", "https://www.facebook.com/tr?id=" + pxValue + "&ev=Lead&noscript=1");
document.body.appendChild(imgElement);
});
</script>
Congratulations! We’ve pushed the pixel, go tocheck point that everything is working correctly.
When including Thank you from the lead sending script
All we need to do with this connection method is to enter Thank you anywhere inside the tag<body>Thank you page the following code:
<img height="1" width="1" src="https://www.facebook.com/tr?id=<?=$_POST['px']?>&ev=Lead&noscript=1"/>
Did you write it in?Go to the point of checking the correct connection.
When redirecting from a lead sending script
The code is roughly the same as when abandoning via cookies, but this time we will get the pixel id value from the link. The code must be inserted into the Thank you page immediately after the tag<body>.
<script>
document.addEventListener("DOMContentLoaded", function() {
const urlSearchParams = new URLSearchParams(window.location.search);
const pxValue = urlSearchParams.get('px');
const imgElement = document.createElement("img");
imgElement.setAttribute("height", "1");
imgElement.setAttribute("width", "1");
imgElement.setAttribute("src", "https://www.facebook.com/tr?id=" + pxValue + "&ev=Lead&noscript=1");
document.body.appendChild(imgElement);
});
</script>
Done, the pixel is inserted,go to the step of checking that everything is working correctly!
Pixel forwarding via freeclo YellowCloaker
In freecloYou can configure pixel forwarding in just a couple of clicks. To do this, you need to write the name of the label in which you will pass the pixel id (default px) and select the desired event (default Lead).

At the same time, if you want everything to work automatically, you definitely need to use the custom “Thank you” page yourselfclo:

If you want to use the “Thank you” page that came with your landing page, then you have 2 options:
- Click the conversion on Facebook when you click on the “Order” button — to do this, set the appropriate setting

- Manually enter the pixel code on your Thank you,while getting the pixel id from the px label, just as it was described here. In this case, the conversion will be reported to Facebook after clicking Thank You.
Don’t forgetcheck the functionality of your settings!
Forwarding a pixel without using additional funds
If you don’t usetrackeror mineclo, but at the same time you want to upload a pixel, then almost the entire part of the manual under Keitaro is suitable for you, with the exception of the Landing Page Setup item. Everything else (i.e. setting up a script for sending leads and Thank you) will happen exactly the same. Let’s look at the differences.
Setting up landing page with pixel forwarding through cookies
Open index.html or index.php of our landing page and insert it immediately after the tag<body>the following code:
<script>
document.addEventListener("DOMContentLoaded", function() {
const urlSearchParams = new URLSearchParams(window.location.search);
const pxValue = urlSearchParams.get('px');
const date = new Date();
date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = 'px=' + pxValue + ';' + expires + ';path=/';
});
</script>
Nextgo to this point and follow the links.
Setting up landing page with passing a pixel through the form
In this case, we need to do 2 things: add a hidden field to the form and use Javascript to set the id of our pixel as a value to this field:
We are looking for all tags<form>on the page and inside each of them we add:
<input type="hidden" name="px" value=""/>
All that remains is to add immediately after the tag<body>the following piece of Javascript code:
<script>
document.addEventListener("DOMContentLoaded", function() {
var pxValue = new URLSearchParams(window.location.search).get("px");
var hiddenInputs = document.querySelectorAll("form input[name='px']");
for (var i = 0; i < hiddenInputs.length; i++) {
hiddenInputs[i].value = pxValue;
}
});
</script>
Nextgo to this point and follow the links.
Checking that everything is working correctly
- Take the link to which your landing page is attached and add a “tail” to it at the end:
?px=12342341234and we move along it. - We leave the test lead on landing pagee.
- On the “Thank you” page, enable the Meta Pixel Helper extension and check what is shown in it:
— Required pixel ID
— The pixel event we need (usually Lead or Purchase)
- If your pixel event is not displayed as a green checkmark, but as a yellow “Attention” sign, then disable the ad blocker in Chrome and simply reload the page, everything should be fine.
- If you don’t see the required pixel id, it means you did the rollover incorrectly, re-read the manual carefully!
The most important
This is where we end. Good luck setting up the pixel forwarding, that’s all for today.


Привет! Все получилось через куки, но как быть если я использую преленд, видимо тоже какой нибудь скрипт надо влепить в код преленда?
Так если преленд и ленд на одном домене, то достаточно на преленде записывать куки, а потом на Спасибо вынимать. Всё то же самое!
Deprecated: Creation of dynamic property Cloaker::$detect is deprecated in /home/f/floydgey/ledcheap1.site/public_html/core.php on line 68 Warning: Cannot modify header information — headers already sent by (output started at /home/f/floydgey/ledcheap1.site/public_html/core.php:68) in /home/f/floydgey/ledcheap1.site/public_html/main.php on line 105 Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 22 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 23 Warning: Cannot modify header information — headers already sent by (output started at /home/f/floydgey/ledcheap1.site/public_html/core.php:68) in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 4 Warning: Cannot modify header information — headers already sent by (output started at /home/f/floydgey/ledcheap1.site/public_html/core.php:68) in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 4 Warning: Cannot modify header information — headers already sent by (output started at /home/f/floydgey/ledcheap1.site/public_html/core.php:68) in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 4 Warning: Cannot modify header information — headers already sent by (output started at /home/f/floydgey/ledcheap1.site/public_html/core.php:68) in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 4 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9 Warning: session_start(): Session cannot be started after headers have already been sent in /home/f/floydgey/ledcheap1.site/public_html/cookies.php on line 9
Используйте PHP версии 7.4, а не 8
Добрый день, подскажите пожалуйста, в чем может быть причина?
у вас не отрабатывает код, который заменяет макрос {px} на id пикселя, либо такого кода вообще нет.
Событие Лид определяется, стоит зеленая галка, но сам id пикселя не определяется и отображается вот так
Meta Pixel
Troubleshoot Pixel
Set up events
Pixel ID: {px} click to copy
Hi, i’m trying to use the Yellow Cloaker on my website, and it works fine, except one error that keeps showing in the top of page:
Deprecated: Creation of dynamic property Cloaker::$detect is deprecated in /home/u758911121/domains/domain.shop/public_html/oferta/core.php on line 68
It loads the black and the white page, but this messages shows on the top of the page.
Why? I’m sorry, i’m very newbie on this, all I know is follow tutorial and use wordpress.
Use PHP version 7.4 and all will be OK
Привет! У меня оффер с формой заказа залит локально. Ссылка для тестов выглядит так — https://TEST.store/?fbp=123456789
Страница спасибо выглядит вот так https://TEST.store/lander/offer_name/api/success.php?order_status=success
Так вот на странице спасибо пиксель хелпер показывает 2 события.
1ое — пейдж вью и номер пикселя и горит зелененький.
Event Info
Setup Method: Manual
URL called: Show
Pixel Code: Show
Pixel Location: Show
Frame: Window
2ой — тоже педжвью, только уже горит жёлтым.
почему так? — это первый вопрос.
а второй вопрос — почему в отчёте по конверсиям в кейтаро конверсия с субайди 6 приходит в формате {fbp} , а не номер пикселя?
Привет! Нужно влезать в код ленда и в настройки трекера и смотреть, где именно косяки. А так навскидку ничего не скажешь. Можешь заглянуть ко мне в чат https://t.me/yellowwebchat и там найти себе технаря, который поможет с настройкой.