Requests
From Admob For Developers
Contents |
[edit]
Building an AdMob Request
AdMob provides publisher code for our Ad publishers and Analytics users in a variety of languages. If we do not currently support your language, this documentation should provide enough information for you to create your own AdMob request.
[edit]
Request Structure
- HTTP POST request to http://r.admob.com/ad_source.php
- The content type is application/x-www-form-urlencoded
- The body of the POST contains urlencoded key/value pairs separated by "&"
urlencode(key1)=urlencode(value1)&urlencode(key2)=urlencode(value2)
- Reserved characters are defined in RFC 3986
[edit]
Request Parameters
Here is a list of parameters that can be used in an AdMob request.
[edit]
Shared Request Parameters
Parameters used for both Ad requests and Analytics requests.
| Parameter | Name | Required? | Description | Example | Source | Notes |
| rt | request type | Required | Determines if the request is an Ad or Analytics request (or both) | rt=1 | AdMob publisher code | rt=0 is an Ad request (default if rt is not sent) rt=1 is an Analytics request rt=2 is a combined Ad and Analytics request |
| u | user agent | Required | The browser user agent of the device making the request | u=BlackBerry8100/4.2.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/100 | Mobile device headers | The user agent string should be urlencoded |
| i | ip address | Required Always required by Analytics | The ip address of the carrier gateway over which the device is connecting | i=72.14.207.99 | Mobile device headers | |
| h[<HEADERS>] | headers | Required | headers that are available with the page request | h[Referer]=http://taptap.net/ | Mobile device headers | |
| o | cookie value | Recommended | 32 character cookie value that uniquely identifies the user on a mobile site | o=de9b5e23ad4fbe48b6bf151a34d56d56 | Publisher | More persistent than a session id. Click here for more information |
| p | page | Recommended | Url of the page where the ad request is called | p=http://m.taptap.net | Mobile device headers | |
| v | version | Recommended | A version string identifying the language and version of the code used to make the request | v=20071126-PHP-1234567890123456 | AdMob publisher code | |
| z | timestamp | Required for Analytics Recommended for Ad requests | Timestamp associated with the request | z=1223957880.39 | Publisher | Seconds since the epoc. For Analytics this must match the timestamp in the pixel url. |
| m | test mode | Optional | If this parameter is set, the ad response is "AdMob Test Ad". | m=test | Publisher | When you want a live ad, do not include the "m" parameter in your request |
| lt | latency | Optional | Allows AdMob to track its worldwide network latency. | lt=0.243 | Publisher | Time passed in seconds. |
| to | timeout | Optional | Current timeout set in the publisher's implementation of the AdMob publisher code. | to=1 | Publisher | Time passed in seconds. |
[edit]
Analytics Request Parameters
Parameters used when making Analytics requests.
| Parameter | Name | Required? | Description | Example | Source | Notes |
| a | analytics site id | Required | The id of the publisher site | a=a12345678901234 | AdMob | |
| title | page title | Optional | Used to name mobile pages as they appear in the output in the Analytics interface | title=video | Publisher | Should be urlencoded |
| event | event | Optional | Analytics allows you to track important events | event=registration | Publisher | Should be urlencoded |
[edit]
Ad Request Parameters
Parameters used when making Ad requests.
| Parameter | Name | Required? | Description | Example | Source | Notes |
| s | publisher site id | Required | The id of the publisher site | s=a12345678901234 | [1] | |
| m | test mode | Optional | If this parameter is set, the ad response is "AdMob Test Ad". | m=test | Publisher | When you want a live ad, do not include the "m" parameter in your request |
| ma | site markup | Optional | Mobile site markup. Where no value is present, xhtml is assumed. | ma=xhtml ma=wml | Publisher | Values: xhtml, wml, chtml |
| e | output encoding | Optional | The output encoding to return for an ad request. Where no value is present, encoding is returned as UTF-8. | e=UTF-8 e=SHIFT-JIS | Publisher | Values: UTF-8, SHIFT-JIS, SJIS |
| f | format | Optional | Format of the ad response | f=html (default) f=html_no_js (not recommended) | Publisher | Values: html, html_no_js (for publishers who do not want javascript ads returned, not recommended because iphone ads will not be displayed) |
| y | ad type hint | Optional | Type of ads that should be returned for this ad request | y=text | Publisher | Values: text, banner (banner is backfilled by text) |
| d[pc] | postal code | Optional | Visitor's postal code | d[pc]=94107 | Publisher | US: zip code UK: postal code Rest of world: standard postal code |
| d[ac] | area code | Optional | visitor's area code | d[ac]=650 | Publisher | The area code from the visitor's phone number (not the country code) |
| d[coord] | location coordinates | Optional | Visitor's geolocation | d[coord]=37.563657,-122.324807 | Publisher | Latitude and Longitude (comma separated) |
| d[dob] | date of birth | Optional | Visitor's date of birth | d[dob]= YYYYMMDD | Publisher | Date of birth, formatted as YYYYMMDD |
| d[gender] | gender | Optional | Visitor's gender | d[gender]=m d[gender]=female | Publisher | Values: m, male, f, female |
| k | keywords | Optional | Space separated keywords | k=sports baseball ny mets | Publisher | If no ad is contextually matched, a highest-expected eCPM ad is returned. |
[edit]
Example Request
Whitespace has been added to make it more readable.
POST /ad_source.php HTTP/1.1 Host: r.admob.com Accept: */* Content-Type: application/x-www-form-urlencoded Connection: Close Content-Length: 676 rt=2& z=1223957880.39& u=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+x86_64%3B+es%3B+rv%3A1.9.0.3%29+Gecko%2F2008092510+Ubuntu%2F8.04+%28hardy%29+Firefox%2F3.0.3& i=127.0.0.1& p=http%3A%2F%2Flocalhost%2Fnick%2Fcurl%2Fcurl.php& v=20080915-PHPCURL-40209f0f2a074ed3& s=a148868283b4b66& a=a14888ba63c29bc& m=test& title=Enter+Page+Title+Here& event=Enter+Event+Name+Here& h%5BHTTP_HOST%5D=localhost& h%5BHTTP_ACCEPT%5D=text%2Fhtml%2Capplication%2Fxhtml%2Bxml%2Capplication%2Fxml%3Bq%3D0.9%2C%2A%2F%2A%3Bq%3D0.8& h%5BHTTP_ACCEPT_LANGUAGE%5D=en-us%2Cen%3Bq%3D0.5& h%5BHTTP_ACCEPT_ENCODING%5D=gzip%2Cdeflate& h%5BHTTP_ACCEPT_CHARSET%5D=ISO-8859-1%2Cutf-8%3Bq%3D0.7%2C%2A%3Bq%3D0.7& h%5BHTTP_KEEP_ALIVE%5D=300
[edit]
Troubleshooting
If you are having problems with the publisher code, sometimes it is useful to determine the exact request that is being sent to AdMob servers. Wireshark is a tool that will let you capture exactly what is being sent over the wire.
