Monday, February 8, 2010

The Code Ascetic - SEO Tracking Tool in 6 Lines of Code

I am going to save you all a bunch of headaches and time staring into the sky for the SEO God's to grant you an effective way to track the conversion from traffic to lead. It is as simple as a few lines of PHP code. I am sure there are equivalents in the other server side scripting languages that someone can kindly post in a reply.

Here is the Snippet.

setcookie("referer", $_SERVER['HTTP_REFERER']);
}
if (is_null($_COOKIE['entrance'])){
setcookie("entrance", $_SERVER['PHP_SELF']);
}
?>

What does this do? It checks if there is a current cookie for both the website passed Referer value and if there is a landing page value. If not, it grabs the referer from the last website the person has been too (including organic google search) and the page that they landed on, for instance, index.htm or /affordable-health-insurance/ becomes the value of $_COOKIE['entrance']

An easy way to check how your cookies are being set is through this simple PHP Script.

You can save a file as test.php and include only the following code:

print_r($_COOKIE);
?>

This prints the cookies you have set in order. Note: Most Dynamic CMS will already have a bunch of Cookies set that you can take advantage of once you figure out their name value through that smalls cript.

The key to web programming is being able to do the most actions with the least amount of code and processing cycles / memory usage. This is similar to being an code ascetic, the more you can go without will bring you to a state of efficiency not many can achieve.  Keep this method for your records! Keep this ideology in your coding!

8 comments:

  1. Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. https://www.sandeepmehta.co.in/affordable-seo-services-delhi/

    ReplyDelete
  2. I’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one web link

    ReplyDelete
  3. One important thing that you must always do is to question a company's SEO strategies and tactics to rule out the use of any negative techniques. digital marketing spokane

    ReplyDelete
  4. Another way to find out about affordable SEO services is by posting your requirements on good SEO forums and community spaces. SEO consultation

    ReplyDelete
  5. Cool you write, the information is very good and interesting, I'll give you a link to my site. seo marketing

    ReplyDelete
  6. Regardless if your business is business-to-business (B2B) or business-to-consumer (B2C), digital marketing can be a fast, often instant, and reliable way of getting leads into your business and driving up revenue. Rocket Agency

    ReplyDelete
  7. Safety and Risk management software can help organizations to manage risks more effectively, improve compliance, increase efficiency, and enhance communication and collaboration, leading to improved business performance and reduced risk.

    ReplyDelete
  8. The expedited services made getting my passport easy! I needed more than standard processing time for my abrupt overseas business travel. I chose the Quick passport service and was satisfied. My passport arrived quickly after I applied. Knowing you can expedite the passport procedure is encouraging when unexpected vacation plans arise. The service makes international travel more accessible and less stressful.

    ReplyDelete