![](http://habrastorage.org/getpro/habr/avatars/c8f/2ce/8ef/c8f2ce8ef9faa113b7b862957b5910e4.jpg)
Google AdSense for Mobile
![](https://habrastorage.org/getpro/habr/olpictures/23d/740/095/23d7400952cfaf3dbcae8a2340208283.gif)
Well, here came the Russian AdSense for mobile. This miracle works in much the same way as AdSense for the web. The only difference is that AdSense for the web uses javascript, and AdSense for mobile works using programming languages:
![](https://habrastorage.org/getpro/habr/olpictures/432/c22/852/432c22852f35c0c5980b7bd2ae361465.gif)
- PHP version 4.3.0 or later
- CGI / Perl version 5.8 or later
- JSP version 1.2 or later
- ASP version 3.0 or later
Unlike the regular version in the mobile, you can install no more than one ad unit per page, in which one or two advertisements can rotate (of your choice).
![](https://habrastorage.org/getpro/habr/olpictures/4c7/d4c/910/4c7d4c9101d6726e38f83469e400e9f6.gif)
At the same time, if you install the AdSense wap-block on your website, then the ads will not be displayed.
![](https://habrastorage.org/getpro/habr/olpictures/320/6c9/c94/3206c9c94fe5e22845d2247795351322.gif)
Of the available options, you can also select a layout: wml, xhtml or chtml (
Well and of course there is the opportunity to customize the color palette - border, link, background, text - and channels.
Personal experience
At the moment, put the mobile version on one site. Used code in PHP. The code is something like this:
$ GLOBALS ['google'] ['ad_type'] = 'text';
$ GLOBALS ['google'] ['channel'] = '***';
$ GLOBALS ['google'] ['client'] = '***';
$ GLOBALS ['google'] ['format'] = 'mobile_single';
$ GLOBALS ['google'] ['https'] = $ _ SERVER ['HTTPS'];
$ GLOBALS ['google'] ['host'] = $ _ SERVER ['HTTP_HOST'];
$ GLOBALS ['google'] ['ip'] = $ _ SERVER ['REMOTE_ADDR'];
$ GLOBALS ['google'] ['markup'] = 'wml';
$ GLOBALS ['google'] ['output'] = 'wml';
$ GLOBALS ['google'] ['ref'] = $ _ SERVER ['HTTP_REFERER'];
$ GLOBALS ['google'] ['url'] = $ _ SERVER ['HTTP_HOST']. $ _SERVER ['REQUEST_URI'];
$ GLOBALS ['google'] ['useragent'] = $ _ SERVER ['HTTP_USER_AGENT'];
require ('http://pagead2.googlesyndication.com/pagead/show_ads.php');
However, during installation, errors immediately occurred with two variables:
$ GLOBALS ['google'] ['https'] = $ _ SERVER ['HTTPS'];
$ GLOBALS ['google'] ['ref'] = $ _ SERVER ['HTTP_REFERER'];
Since the variables $ _SERVER ['HTTPS'] and $ _SERVER ['HTTP_REFERER'] were missing, the corresponding error was thrown. I had to slightly correct the code for:
$ GLOBALS ['google'] ['https'] = isset ($ _ SERVER ['HTTPS'])? $ _SERVER ['HTTPS']: '';
$ GLOBALS ['google'] ['ref'] = isset ($ _ SERVER ['HTTP_REFERER'])? $ _SERVER ['HTTP_REFERER']: '';
Then it all worked. True, I have not seen the ads yet. AdSense’s settings on this say, “As soon as the code is added to the WAP site, relevant ads should appear on it within 48 hours.” I will wait :)
PS If someone has experience installing code in languages other than PHP, and you have any problems, write how you dealt with them. I think others will be very interested.
Update
By the way, judging by this parameter $ GLOBALS ['google'] ['ad_type'] = 'text', not only text, but also image ads will be available in the future.
Update 2
Here are the first swallows. Found two problems:
1. The & sign is transmitted explicitly in the URL to the advertising link. And this means that in Opera mini, for example, the site will give a markup error. In general, this is a jamb.
2. The encoding is transmitted as UTF-8. On the one hand it’s good. But on the other hand, if the site runs on PHP, for example, using ob_start () and then transcoding WINDOWS-1251 to UTF-8, then the encoding of the ad breaks and shows flashes.
Update 3 I also
found that the ad at the exit is already placed in
Ojava
. Wap masters know what this means :)