Facebook ads - fbclid error
4 posts by 2 authors in: Forums > CMS Builder
Last Post: Tuesday at 4:07pm (RSS)
By theclicklab - Tuesday at 12:05pm - edited: Tuesday at 12:05pm
Hi, Getting errors with clicks from facebook ads. What do we need to do to ignore the fbclid query string? e.g.
https://www.luxurychartergroup.com/fr/yacht-type.php/sailing-1/?fbclid=IwZXh0bgNhZW0CMTEAAR7fTQ-i0Wqhbb9AcxZH7diA0z0D8ZZP7LoAuS2-ye-86BO_GJ8hKRYcGLq97w_aem__zv4OF5lCj9Fz28JdJBg8Q
Error:
Warning: Trying to access array offset on value of type null in /home/luxurychartergroup/luxurychartergroup.com/fr/yacht-type.php on line 28Warning: Cannot modify header information - headers already sent by (output started at /home/luxurychartergroup/luxurychartergroup.com/cms/lib/errorlog_functions.php:113) in /home/luxurychartergroup/luxurychartergroup.com/fr/yacht-type.php on line 32Warning: Cannot modify header information - headers already sent by (output started at /home/luxurychartergroup/luxurychartergroup.com/cms/lib/errorlog_functions.php:113) in /home/luxurychartergroup/luxurychartergroup.com/404.php on line 1Warning: Cannot modify header information - headers already sent by (output started at /home/luxurychartergroup/luxurychartergroup.com/cms/lib/errorlog_functions.php:113) in /home/luxurychartergroup/luxurychartergroup.com/404.php on line 2
Many Thanks :)
What is each of these lines:
/home/luxurychartergroup/luxurychartergroup.com/fr/yacht-type.php -> line 2
/home/luxurychartergroup/luxurychartergroup.com/fr/yacht-type.php -> line 32
/home/luxurychartergroup/luxurychartergroup.com/404.php -> line 2
It looks like your site is grabbing the GET variable from the URL (in this case fbclid) and then using that to find a page/record in your database. It can't, so 404s.
My guess is your code is something like:
If there's a GET variable, use that to find the page
...but you're doing it for ANY GET variable, so it's using fbclid instead of whatever correct variable you use to get the correct page.
Proof of Concept:
https://www.luxurychartergroup.com/fr/yacht-type.php/sailing-1/?foo=bar
This also errors and 404s.
You need to harden your code to correctly define which GET variable you want to use, rather than any. If you show those lines, it'll likely be an easy fix.
Cheers
Rob
By theclicklab - Tuesday at 1:17pm - edited: Tuesday at 1:18pm
Thanks Rob for those tips, I solved this.
foreach($_REQUEST as $key => $item){
if($key != 'page' && $key != 'sort' && $key != 'gclid' && $key != 'fbclid' && $key != 'msclkid' && strpos($key, 'utm') === false){
$recordNum = preg_replace("/[^0-9,.]/", "",$item);
break;
}
}
By runriot - Tuesday at 4:07pm
Hey,
Not sure on your end goal with $recordNum, but that code will still pass fbclid (and those others) to your $recordNum, which could potentially still cause problems down the line.
Without seeing what you then do with $recordNum, I'm guessing it's used in a mysql_get/select to get the page record?
Cheers