KitzKikz  KitzKikz: GoogleAnalyticsNoScript   RecentChanges 
 PopularPages 
 SearchPages 
 Home | Trail - KitzKikzHobby > TestCase > KitzKikz > KitzKikzDownloads > GoogleAnalyticsNo... > GmailAtomReader
 
Learn Spanish Learn Spanish Today Learn Spanish - Learn Spanish on-line for free, using interactive audio/visual lessons.
 

Google Analytics gathers a good deal of useful information and presents it in some nice ways, but only if ALL your users have javascript turned on in their browsers. People who browse your site with javascript turned off are essentially invisible when it comes to the Google Analytics code.

However, the Google code just builds a special url to a 1x1 image and then loads that image each time the page is browsed. It's this loading of the image and all the additional information in the url that gives Google Analytics the statistics it needs.

Therefore, by determining the actual url used, you can include it as an image tag inside the <noscript>...</noscript> tags. Then, if users have javascript turned on, the normal Google code is used. If they have javascript turned off, the <noscript> area is used, loading the image directly.

Determining this special url is not easy. Fortunately, someone has already done that for us here. Unfortunately, it's based upon some older version of Google Analytics. With some minor modifications, however, I came up with the following in my php served pages.

     <noscript><img src="<? echo google_analytics_noscript(); ?>" /></noscript>

With the function definition of:

     function google_analytics_noscript() {
        $var_utmac='UA-???????-1'; //enter the new urchin code
        $var_utmhn=$_SERVER["HTTP_HOST"]; //enter your domain
        $var_utmn=rand(1000000000,9999999999); //random request number
        $var_cookie=rand(10000000,99999999); //random cookie number
        $var_random=rand(1000000000,2147483647); //number under 2147483647
        $var_today=time(); //today
        $var_referer=$_SERVER['HTTP_REFERER']; //referer url

        $var_uservar='-'; //enter your own user defined variable
        $var_utmp='noscript'.$_SERVER["REQUEST_URI"];

        $img='http://www.google-analytics.com/__utm.gif?utmwv=4.3'
            .'&utmn='.$var_utmn
            .'&utmhn='.$var_utmhn
            .'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-'
            .'&utmr='.$var_referer
            .'&utmp='.$var_utmp
            .'&utmac='.$var_utmac
            .'&utmcc=__utma%3D'.$var_cookie.'.'.$var_random.'.'.$var_today.'.'.$var_today.'.'.$var_today.'.2%3B%2B__utmb%3D'
            .$var_cookie.'%3B%2B__utmc%3D'.$var_cookie.'%3B%2B__utmz%3D'.$var_cookie.'.'.$var_today
            .'.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'.$var_cookie.'.'.$var_uservar.'%3B';

        return $img;
     }

 

 
Free Spanish Lessons
 

 
 EditThisPage · LinksToPage · PageInfo 02/08/09 22:06:28  ·  0.0376s