Anyone know an off the shelf php script to simply process a common log format web stat file and insert the field results into a mySQL table? I could roll my own but it's late and I'd rather use someone else's hard work......
I have one but I use very less fields. Time, referrer, IP and page_name. I identify page name by its unique name and use a format to identify them. You have to add one unique identification name to each page. So if you have one existing site with many pages then it will take lot of time.
Hey smo, can you PM me the script as well please? I'm looking to develope some software that uses what your script does. I'll email you a copy of my script when I'm done.
I'm going to be logging the activity of users that come from the search engines and calculating which keywords resulted in sales. Interested mnemtsas?
Ah well you know I'm already doing this, tracking adwords mostly. I knocked something up last night to do it. I'm just looking for something to go through all my old log files so I can do historical stuff too. My payment provider has only just started logging IP's so I've only just been able to do it. I'm happy to show mine if you show yours!
lol ok Then maybe we can combine our scripts and come up with a piece of software every webmaster will want and will pay us $200 a time to use it.
Well here's my code for recordings stats from sites I'm interested in. The sale IP matching code is still under development. Know any good code to pull the search terms from google/yahoo/msn? <?php include("inc/settings.php"); $tracked_referers=array('.capterra.','.business.com','.google.','.sharewareratings.','buyjoggingstrollers','vgcity'); $referer=$_SERVER['HTTP_REFERER']; if (!strlen($referer)==0) { $matched_referer=0; for ($i=0;$i<count($tracked_referers);$i++) { if (stristr($referer,$tracked_referers[$i])) { $matched_referer=1; } } if ($matched_referer) { $ip=$_SERVER['REMOTE_ADDR']; $landing_page=$_SERVER['PHP_SELF']; $keywords=$_GET['kw']; $date_array=getdate(); $day_start=$date_array["mday"]; $month_start=$date_array["mon"]; $year_start=$date_array["year"]; $referer_date=sprintf("%04d%02d%02d", $year_start,$month_start, $day_start); $sql="INSERT INTO referer_log (ip,referer,landing_page,adword_keyword,referer_date) VALUES ('$ip','$referer','$landing_page','$keywords','$referer_date')"; //echo $sql; $link_id = @mysql_connect($hostname,$userid,$userpassword); @mysql_select_db ($db_name); @mysql_query($sql,$link_id); } } ?> Code (markup):
Well I know awstats does it but I was thinking of just scraping the keywords from the referred URLs. It would probably take me about 30 minutes to write the code and another 30 to display it lol.
No I didn't. But I must admit that adding different things to make up the characters amuses me. You know what they say about simple things and simple minds.....
Weirfire, I found some great php code that parses out the keywords from every search engine referrer I've ever heard of. Works pretty well. Let me know if you're interested and I'll PM it over to you.