Slow PHP redirects lead to loss of marketing clicks

Slow PHP redirects lead to loss of marketing clicks - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Slow PHP redirects lead to loss of marketing clicks error on your web browser. Problem :


Ok so we are running liquid web server



For some reason we are losing around 70% of all of our clicks that we are tracking on our end than we are seeing on Hasoffers tracking platform.



These are mobile clicks so we expect to loss a bit but not 70%



They say it can be a number of things that is causing this but I want to break it down here and show what we have so you can take a look at this a bit better and try to help us out.



So we are running traffic to variations of this link here



alengetcheck.us



For each phone number that we have we create a different domain.



So for instance alengetcheck.us/pndq8q is associated with 12547098787 and alengetcheck.us/pn7894 may be associated with 789278299



When sending out we do not use any sort of an HTTP, HTTPS or even WWW. We just run it as is the domain and the extension.



So the problem we are having is that when we are redirecting from alengetcheck.us/pndq8q to the other page it is taking about 1.7 seconds when we use a speed test and our score is very poor due to slow speed.



So the only thing that our system does is takes a link and redirects it. Very simple as we just have to redirect to the link set inside the link in the domain.



This is the script that we are currently using to redirect the link:



<?php 
function get($url, $params=array())
$url = $url.'?'.http_build_query($params, '', '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);


$link = get('http://aptrack.us/get_link.php', array('code'=> $_GET['code']));
echo "<script>window.location='".$link->url."';</script>";
?>


As you can see this is a very simple script and it shouldn't take 1.7 to redirect to the next page. It should take milliseconds.



So what should we do on our end now to make this go faster?



Is there anything wrong with our script or our calls that you see would cause a split second lag?



How can we reduce server response time to 200MS which is what Google is wanting from us right now?



Any help or suggestions would be great!


Solution :

Just what Itai wrote, I am also confused what you are trying to achieve with your code.



What is the expected output from your Get-function? And why do you json_decode it?



If, for example you need to translate your ID (pndq8q or pn7894) to a number, then why is this relevant for redirection? I suspect you have those Hashes, then grab their corresponding ID from a list or database and then do the same thing again, but against your ID instead of the hash.



Why not grab the final URL directly?



Fake code



<?php 
function get($hash)
// lookup your final link by your hash in your DB, store as $data
return $data;


$link = get($hash); // this would be i.e. get('pndq8q');
header('Location: '.$link);
?>

We hope that this article has helped you resolve the redirects, performance, marketing error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=