craigbruiners Posted March 9, 2007 Share Posted March 9, 2007 <? if ($COOKIE['visitor_language']== "en") { $lg_id = "UA-1436977-1"; } elseif ($COOKIE['visitor_language']== "fr") { $lg_id = "UA-1436987-1"; } elseif ($COOKIE['visitor_language']== "de") { $lg_id = "UA-1436993-1"; } elseif ($COOKIE['visitor_language']== "nl") { $lg_id = "UA-1436998-1"; } else { $lg_id = "UA-1437004-1"; } ?> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "<?=$lg_id?>"; urchinTracker(); </script> It goes through this code once the user comes into the site from the different countries. Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 12, 2007 Author Share Posted March 12, 2007 Can anybody help me with this please?? Will really appreciate it. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 12, 2007 Share Posted March 12, 2007 if you ask "if this works" we will assume it doesn't work yet you have not cared to explain why it doesn't work? maybe an error...something??? from just reading it looks like it works, of course this depends on cookies already being set, I don't see the code where you set the language cookie for the user Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 12, 2007 Author Share Posted March 12, 2007 Well i just wanted you to check if there was any syntax error in the code, seeing that it doesn't wanna work, and seeing that you said that the code is fine, thanks alot for that hey, and thanks alot for ur reply, really appreciated. This is where we set the language in the cookie. This is the code for the cookies: <? /* Script to run at starup */ /* Detecting browser's default language */ if (!isset($_COOKIE['visitor_language'])) { $BrowserLang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2); switch($BrowserLang) { case "en": $_SESSION['DEFAULT_LANG'] = "en"; break; case "fr": $_SESSION['DEFAULT_LANG'] = "fr"; break; case "de": $_SESSION['DEFAULT_LANG'] = "de"; break; case "nl": $_SESSION['DEFAULT_LANG'] = "nl"; break; case "es": $_SESSION['DEFAULT_LANG'] = "es"; break; } } /* Set Default site language region */ if (!isset($_COOKIE['visitor_language'])) { if (getenv('HTTP_X_FORWARDED_FOR')) { $visitor_ip = getenv('HTTP_X_FORWARDED_FOR'); } else { $visitor_ip = getenv('REMOTE_ADDR'); } $VisitorInfo = file('http://api.hostip.info/get_html.php?ip='. $visitor_ip .'&position=true'); if($VisitorInfo != "") { $VisitorRegion = substr($VisitorInfo[0], -4, 2); switch($VisitorRegion) { case "FR": $_SESSION['DEFAULT_LANG'] = "fr"; break; case "DE": $_SESSION['DEFAULT_LANG'] = "de"; break; case "NL": $_SESSION['DEFAULT_LANG'] = "nl"; break; case "ES": $_SESSION['DEFAULT_LANG'] = "es"; break; } } } /* Register default language in cookie */ $time = time(); if (isset($_COOKIE['visitor_language'])) { $_SESSION['DEFAULT_LANG'] = $_COOKIE['visitor_language']; setcookie ("visitor_language",$_SESSION['DEFAULT_LANG'], $time+(60 * 60 * 24 * 60)); } else { $visitor_lang_pref = $_SESSION['DEFAULT_LANG']; setcookie ("visitor_language",$visitor_lang_pref, $time+(60 * 60 * 24 * 60)); } ?> Hope this will give u more detail, thanks again. Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 12, 2007 Author Share Posted March 12, 2007 So will the code work with the cookies file? Thanks again Quote Link to comment Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 So will the code work with the cookies file? Why don't you test it and tell us. Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 12, 2007 Author Share Posted March 12, 2007 Well im testing it the whole time and ran out of ideas of how to make this thing to work, coz my one friend in France is testing and when he goes to the website it brings back the english number $lg_id = "UA-1436977-1" instead of the french number $lg_id = "UA-1436987-1", so how do i go from here, coz i've came to this point where im stuck and feel so stupid(then i ask myself what am i doing in programming). Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 12, 2007 Author Share Posted March 12, 2007 Any solution or do u need more detail???? Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 13, 2007 Author Share Posted March 13, 2007 Anybody there????? Please guys i really need help here. Im on bended knees here. Thanks again ??? ??? Quote Link to comment Share on other sites More sharing options...
craigbruiners Posted March 14, 2007 Author Share Posted March 14, 2007 Can Anybody Help me please, please Thanks in advance Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.