If you work with a large number of accounts at once (especially if you work via Dolphin), you can face the problem of placing each Facebook pixel code on the “Thank you” page. If you enter it manually, you will have to prepare separate flows for each account and spend a lot of time.
We need to configure everything so that the pixel is written on the “Thank you” page automatically. We used a bunch of Keitaro (using the CPARIP promo code) and KMA.biz affiliate, so let’s look at the example. Pre-landing and Landing are uploaded locally and the transfer of leads to the affiliate is done via API.
Forwarding a pixel via Keitaro
It all comes down to the fact that the pixel ID is passed via the incoming URL as a GET parameter.
We will get the pixel number by adding &fbp=pixel_numbe
r to the ad link.
- In the tracker, we add the
&fbp={fbp}
offer parameter in the affiliate network settings. This is necessary for the forwarding from pre-landing to the landing page.
- Next, the pixel number received in the link will be forwarded through the order form, which is processed by the success.php file
- To do this, add the following line to the order form
<input type="hidden" name="fbp" value="{fbp}"/>
- Keitaro will automatically substitute the pixel received in the link instead of {fbp} and then it will go to the handler. The only thing to do is to take it and add it to the thank you page.
- In the api/success.php file add the line
$_SESSION['fbp'] = $fbp;
as in the screenshot:
- Next, in the api/template/success.php file add the line
$fbp = isset($_SESSION['fbp']) ? $_SESSION['fbp'] : '-';
- In api/template/success.php we use the cut-down Facebook pixel
<img height="1" width="1" src="https://www.facebook.com/tr?id=PIXEL_NUMBER&ev=Lead&noscript=1"/>
We need to insert our received pixel number with the help of <?= $fbp ?>.
Done. Now each account will have its pixel number on the “Thank You” page.
Let’s consider a few more variants
The general principle is clear. Depending on the way of connecting landings on Keitaro and the peculiarities of realizing the transfer of leads in each affiliate, the methods of transfer will differ.
The same but without Keitaro
- In the same way, we forward the pixel to the landing page in the ad link
&fbp=pixel_number
- To pull the pixel from the link to the very beginning of the landing index.php file add:
<?php $fbp = (isset($_GET['fbp'])) ? trim($_GET['fbp']) : ''; ?>
- And add to the order form:
<input type="hidden" name="fbp" value="<?=$fbp?>" />
- Further, as in the case with Keitaro, we pass the success.php to the “Thank you” page.
If the forwarding to the “Thank you” page is done via redirect
When the “Thank you” page is connected as a regular URL and the redirects go to it, the pixel should be passed as a parameter, and on the Thank you page we should pull it out of the URL and put it into the pixel code.
- We need to add the received pixel to the redirect link:
https://domain/success.php?fbp=<?=$fbp?>
- and get it again from the link on the thank you page:
<?php $fbp = (isset($_GET['fbp'])) ? trim($_GET['fbp']) : ''; ?>
- and add it to the pixel code:
<img height="1" width="1" src="https://www.facebook.com/tr?id=<?=$fbp?>&ev=Lead&noscript=1"/