iExpertsForum Community
May 22, 2013, 10:23:43 AM *
Welcome, %1$s. Please login or register.

 
      
  Print  

Author Topic: Tracking URl & keyword in PHP  (Read 825 times)

robin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Tracking URl & keyword in PHP
« on: August 10, 2009, 12:12:46 AM »
Hi all,
I need to know that what is the way i can track my url in php. i am new to it please help.

william

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Tracking URl & keyword in PHP
« Reply #1 on: August 10, 2009, 12:13:58 AM »
I have asked my web designer to track the URL and Keyword for each click coming from my Adwords campaigns usin the HTTP_REFERRER variable but he seems to think that when my online form is submitted, it will only track the last URL.

Can someone who has PHP experience please give me a short briefing on what I should be telling my programmer to enable him to capture the first URL when a user enters my site from a campaign so that we can assign the URL + Keyword to each form submission.

The reasoning for this is that it will enable me to track what keywords from my my website leads convert to actual deals!

Thanks

jackal86

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Tracking URl & keyword in PHP
« Reply #2 on: August 10, 2009, 12:15:34 AM »
Your programmer is right, the formal definition of the $_SERVER['HTTP_REFERER'] variable is the following: "The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted."

So, yes, the "HTTP_REFERER" only tracks the last URL.

However, there is a simple way around it. When users come to your website, check if they already have the cookie "first_http_referer" and if they don't have it, set the value of the cookie "first_http_referer" to $_SERVER['HTTP_REFERER'].

This way you will always have the information you want saved in user's cookie - and the information won't get overwriten as your user continues to browse around your website.

I hope I've helped you with my reply.

jeremy

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Tracking URl & keyword in PHP
« Reply #3 on: August 10, 2009, 12:18:08 AM »
The way you programmer is doing, by using session cookies, is the preferred way. I would use a similar approach and would set a session cookie once a user visits your page and do subsequent checks to see if the session cookie was already created on the other pages he/she might visit. The session cookie would only be set if the referrer host contains the domain (or part of the domain) for the search engines that you are targeting and the respective keyword.

Regarding cookies, almost all browsers accepts *SESSION* cookies by default and security software often don't block it... but persistent cookies can be blocked by security software by default and/or by users.

Even if session cookies were blocked, there are other ways to keep track of the info - for example by appending the session id to the url or hide it in a form, but for this case I wouldn't do it because it can be very complex to implement it, depending on the way your web pages are created.

Tip: tell you programmer to check the "parse_url" and "parse_str" at php.net to parse the referrer url and the query string, as it might help to simplify the code.

  Print  
 
 

Powered by MySQL Powered by PHP SMF 2.0.3 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!