War Room

Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Featured Warrior Special Offer...
"Members Of The *War Room* Discover Secrets To Immediate Success!"
Reply
 
LinkBack Thread Tools
Old 10-01-2009, 04:58 AM   #1
Active Warrior
 
Join Date: Apr 2007
Location: , , Ireland.
Posts: 74
Thanks: 0
Thanked 1 Time in 1 Post
Default How to retrieve http header info

I have a site that gets good traffic from Google and I want to track what keywords are converting from the natural searches.

Can anyone tell me how I can use php to grab the keyword information when someone lands on my page after finding it on a search engine.

I will then attach that keyword to a variabl (I can do this part )

Cheers,
Dave
DavidMeade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2009, 10:14 AM   #2
Active Warrior
 
Join Date: Jul 2006
Location: , , South Africa.
Posts: 49
Thanks: 0
Thanked 3 Times in 3 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via Skype™ to holla22
Default Re: How to retrieve http header info

Hi you can grab a url string variable sent through google and store it in a msql database.

Look for the this code in the url string. "www.google.co.za/search?q=make+money&ie=utf-8&oe=utf-8&aq=t&client=firefox-a&rlz=1R1GGGL_en___ZA347"

where q=make+money is what you want to store

so you will get the variable by doing the following

$keyword = $_GET['q'];

This will store the search term in a variable called "keyword" now you just need to store the variable data in the in the mysql database table.

Hope this is useful?

Visit http://www.superimtips.com for the latest IM tips and news
holla22 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2009, 11:09 AM   #3
Web Developer
 
wayfarer's Avatar
 
Join Date: Nov 2008
Location: Asheville, NC USA
Posts: 151
Thanks: 1
Thanked 23 Times in 21 Posts
Default Re: How to retrieve http header info

That's not really a helpful solution, and is actually incorrect. The $_GET variables are only available if they are present in YOUR website URL.

I believe the only way to do this is with the "referer" (notice the incorrect spelling, it is actually correct). The referer header doesn't always get sent by the browser, but it is usually there.

http://www.electrictoolbox.com/php-h...erer-variable/

You should then dissect the url string to find what keyword is being searched for. The search term in a Google search looks something like this:
Code:
http://www.google.com/search?q=hello+world&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
Here, I searched for "hello world". So, the term is in the "q=hello+world" part. You will need the PHP function urldecode to get the literal string. To get that string, you will need to explode the url string, first at the "?" deliminator, then at the "&" delimiter. Then, cycle through the second array, and when you have the string "q=" at the beginning of an item, remove it, and what is left is the search term. This sounds complicated, but it isn't that bad.

wayfarer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2009, 11:59 AM   #4
Advanced Warrior
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 972
Thanks: 106
Thanked 143 Times in 103 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: How to retrieve http header info

Wayfarer is correct. You have to look at the REFERER. I found this code here. It seems to work fine in a quick test.

PHP Code:
$parsed_url=parse_url($_SERVER['HTTP_REFERER']);
if(
stripos($parsed_url['host'],'google'))
{
parse_str($parsed_url['query'],$parsed_query_string);
$keyword_string=$parsed_query_string['q'];

Steve

Executive I.T. consulting for small/medium business
Website development | PHP - MySQL - JavaScript expert programming
Software requirements analysis | Specification writing
Project management | Vendor relationship management
Steve Diamond is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2009, 02:39 PM   #5
Active Warrior
 
Join Date: Jul 2006
Location: , , South Africa.
Posts: 49
Thanks: 0
Thanked 3 Times in 3 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via Skype™ to holla22
Default Re: How to retrieve http header info

Oh well that is the way I'm doing it and it works fine for me. Yes you obviously want to see who the referrer is like google, yahoo, bing etc, but that was just a simple quick explanation. I just thought that you already knew the rest

Visit http://www.superimtips.com for the latest IM tips and news
holla22 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2009, 04:16 PM   #6
Active Warrior
 
Join Date: Apr 2007
Location: , , Ireland.
Posts: 74
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: How to retrieve http header info

hey fellas,

thanks for your help with this, much appreciated.

Dave
DavidMeade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
header, http, info, retrieve

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 11:29 AM.