Tags: mobile
Google Analytics for Mobile Sites
2008/05/23 @ 20:13I implemented tracking using Google Analytics for my company's mobile sites using a technique described by Peter van der Graff on his site. The technique involves performing a GET to to an image on Google's server and passing it a bunch of options. Incidentally this is because Javascript can perform gets of images but not gets for any other kinds of content (as an aside, this kind of protection seems usless since the server could return any kind of content in wants to the javascript even though the GET has an image in the url. Maybe someone could enlighten me).
Peter originally came up with the idea because he wanted to track hits to a RSS xml url (which also seemed strange to me since the rss aggregator could read it as many times as it wants and doesn't give much insight into the number of readers, but I digress), or to another type of file download (image, pdf, etc) which wouldn't trigger the javascript that Google uses for Analytics.
One important difference between his motives and mine were that I'm tracking hits to a mobile site. Doing analytics on the server side are important since most phones (in Japan at least) don't support javascript. I also, because of the differences in what I was doing, needed to make some changes to how his script worked. Since I'm not tracking downloads or rss hits, I care about things like sessions, language, and user agent (why Peter didn't also care about this I'm not sure).
So I modified his code as follows. I forward the language and user agent of the client to Google Analytics so that I can track these things properly. I also pass my own cookie number so that Google Analytics can aggregate page hits from the same user into a session. I also make use of the user var to track hits to different customer's web pages. The example is in PHP but it could be easily translated into another language.
Note that, because of the use of stream contexts, this code will require a version of PHP >= 4.3.0.
| $var_utmac=MOBILE_GOOGLE_ANALYTICS_CODE; //enter the new urchin code | |
| $var_utmhn=WEB_DOMAIN; //enter your domain | |
| $var_utmn=rand(1000000000,9999999999);//random request number | |
| $var_cookie=$session; //cookie number | |
| $var_random=rand(1000000000,2147483647); //number under 2147483647 | |
| $var_today=time(); //today | |
| $var_referer=$_SERVER['HTTP_REFERER']; //referer url | |
| $var_uservar=$storeinfo['storeid']; //enter your own user defined variable | |
| $var_utmp=$_SERVER['REQUEST_URI']; // request uri | |
| $urchinUrl='http://www.google-analytics.com/__utm.gif?utmwv=1&utmn='.$var_utmn.'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='.$var_utmhn.'&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'; | |
| $header = ''; | |
| //Set the language to that of the client so analytics can track it. | |
| if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { | |
| $header = 'Accept-language: '.$_SERVER['HTTP_ACCEPT_LANGUAGE'].'\r\n'; | |
| } | |
| //Set the user agent to that of the client so analytics can track it. | |
| if (!empty($_SERVER['HTTP_USER_AGENT'])) { | |
| $header = 'User-Agent: '.$_SERVER['HTTP_USER_AGENT'].'\r\n'; | |
| } | |
| $opts = array( | |
| 'http'=>array( | |
| 'method'=>'GET', | |
| 'header'=>$header | |
| ) | |
| ); | |
| $handle = fopen($urchinUrl, 'r', false, stream_context_create($opts)); | |
| $test = fgets($handle); | |
| fclose($handle); |
iPhone Mobile phones are not Desktops
2008/03/31 @ 23:28
While John C. Dvorak generally writes flamebait that you shouldn't pay attention to, there is usually a nugget of truth that flamebait. This time Mr. Dvorak points out that iPhones are not desktops. He says iPhones but he really means all mobile devices of various shapes and sizes from mobile phones to laptops. The idea that mobiles are not desktops might seem obvious.
"Duh, a desktop is not mobile" you might think but the point is really about building applications. Are people willing to trust putting their personal data into a mobile device that is easily lost, stolen, dropped in a toilet or otherwise damaged? Recent research demonstrated that we can't even trust laptops where the hard drive has been encrypted if it's turned on or in sleep mode. I'm not sure how many criminals carry around aerosol canisters to cool memory down or have the technical knowhow to take advantage of this flaw. That sounds like the work of more organized crime; most stolen laptops in the news so far seem to have been stolen by regular thieves who aimed to sell it on the black market. But how many individual people actually have an encrypted partition on their personal laptop? I have heard of a few instances of people doing that on the Gnucash mailing lists but I would venture to guess that the answer is not many. And an encrypted partition on an mobile is out of the question. Many phones have a key that they use to lock the phone but how many people turn it off or lock it when they aren't using it?
Security isn't the only concern with mobile development either. Mobiles, almost by definition, are conspicuous devices that allow us to stay connected even when away from the computer. This is powerful but understanding that a mobile device is *mobile* is critical to properly managing the data that's on it as well as our behaviour when using the device. Depending too much on the devices for normal work that should be done on the desktop is most likely not going to work well. Dvorak makes a number of points about why the desktop computer is the best platform. Essentially the desktop is better at everything compared to the laptop except in portability. Portability is a big factor but essentially it means that when you are at home or at work, use a desktop and when you are travelling use a mobile (A hammer for a nail, a screwdriver for a screw etc.). Use the best tool for the job. Update: Dvorak forgot one more advantage of mobiles, energy efficiency.
In the end it feels like the tech industry is jumping to mobile simply because it's unexplored territory (read not monetized yet), even when the desktop hasn't really been fully explored yet.
OLPC Geeks
2008/01/19 @ 17:24I have been reading the OLPC News blog for a while now and frankly I'm kind of tired of hearing about how American geeks are complaining that it's hard to get an XO or that it has taken a while for them to get their XO laptop or that the box was empty when it arrived. Here's a clue for those who are wondering why OLPCs service is sub-par. The XO laptop is was not made for American gadget addicts.
| Nothing irks me more than seeing staged photos of playful American geeks fighting over their new gadget that they have no business having in the first place. And then at the same time they complain that OLPC's service is not good. Boo hoo. My shiny toy is broken. I can't believe the silliness. The last person who needs an OLPC laptop is an American computer geek and yet they complain about OLPC and having to wait a long time on the phone to get service. Think about it. OLPC is not DELL. Grow a brain. |
If you will be doing OSS development (seriously, not just pretend) on the XO that will be used in developing countries, fine. But most will not. This guy even says that it's a toy and he doesn't know how he'll even use it. Most recieving an XO laptop would say that they are OLPC enthusiasts and that they think that OLPC is a great idea and that it would help the developing world a lot. I agree. But I am not itching to get an OLPC laptop. I will not do any development on one and I'm not a child in a developing country so I have no business having one. OLPC may have instigated the Give 1 Get 1 program themselves but think about it, Nicholas Negroponte said that having an XO if you aren't a child should be a badge of shame. I think that's true, whether you stole it or got it from the Give 1 Get 1 program.
| Those recieving an XO laptop might say they are donating to OLPC out of the goodness of their hearts and recieving an XO is just icing on the cake. BULLSHIT. If they cared about children in the developing world they would donate the the laptop they were going to recieve too. Forget the Give 1 Get 1. How about the Give 2 program? American geeks would drop OLPC like every other passing fad that crosses their impatient minds. THEY ONLY CARE ABOUT OLPC BECAUSE THE LAPTOP IS COOL. Period. No other reason. | ![]() |
Gmail on Japanese Mobiles
2006/12/13 @ 11:17![]() |
I've used Gmail for my personal mail for almost 2 years now. But I had never had a phone where I could access the internet from the cell phone until I came to Japan. So I was delighted to know that Gmail has a mobile feature that allows me to read e-mails from the cell phone.
However, it's not all Samurai's and Green Tea here in Japan because Gmail doesn't work on Japanese mobiles. In fact almost none of Google's services work on the cell phone. Google has a news reader that you can access from your mobile phone as well. But that doesn't work either. The simple search seems to work ok but any service where you need to log in fails and Google doesn't support Japanese phones.
Each service complains that you need cookies enabled in your browser in order log in. Though cookies are enabled in the browser and other Japanese sites like Mixi have no problems logging you in.
I tried searching the internet for possible causes and solutions to the problem and I came across a few websites but nothing seemed to work. This site seems to suggest that at first there is a possibility that it would fail but if you login again it would work. But nothing seemed to work for me and gmail seems to spend you to a page that isn't for mobiles.
I suppose all of this could be my phone's lousy browser implementation but lots of phones in Japan seem to have the same problem. I suppose the lack of resources in Japanese, not supporting Japanese phones and not having services useful to Japanese (like train schedules etc.) is why people in Japan tend to use Yahoo and not Google. Yahoo just serves Japanese people better. And besides the messenger has cuter smilies ![]()











