Cookies

From Admob For Developers

Jump to: navigation, search

Contents

AdMob Cookies

The latest version of AdMob's publisher code now supports the use of cookies. When a new user visits your website, the publisher code will set a cookie on behalf of AdMob. The value of this cookie is a 32 character string that anonymously identifies this user on your website.

Benefits

Cookies improve AdMob's ability to anonymously identify users. This benefits publishers by providing:

  • Improved ad targeting > Higher click through rates > More revenue
  • Improved analytics data for analytics.admob.com

Setup

Download the latest publisher code from www.admob.com or analytics.admob.com. Depending on the language you use, you may or may not need to do some extra configuration to take advantage of AdMob cookies.

C#, Java, VB.NET, VBScript (ASP)

By default, these languages buffer responses and AdMob cookies will work without any additional setup.

If you are using one of these languages and have configured your environment to stream responses, then the "AdmobRequest()" function will be unable to automatically set an AdMob cookie.

  • To set an AdMob cookie you will need to explicitly call the "AdmobGetCookieValue()" function on each page that calls AdmobRequest()
  • The call to "AdmobGetCookieValue()" must occur before the HTTP headers for the response have been sent (i.e. before the script produces any output).

PHP, Perl

By default, these languages stream responses so you will need to perform additional setup to take advantage of AdMob cookies.

  • To set an AdMob cookie, simply call admob_setcookie() on every page that you call admob_request().
  • The call to admob_setcookie() must occur before the HTTP headers for the response have been sent (i.e. before the script produces any output).
  • If your mobile site uses multiple subdomains (e.g. "a.example.com" and "b.example.com"), then pass the root domain of your mobile site (e.g. "example.com") as a parameter to admob_setcookie().

Ruby

Read our documentation at http://admob.rubyforge.org/admob/

Multiple sites on the same domain

If you are a publisher that hosts multiple mobile sites on the same domain, you will need to restrict the scope of the cookie so that accurate stats can provided across multiple campaigns hosted on your service. This is done by setting the cookie path.

PHP

To restrict the scope of the cookie in PHP, simply pass in the domain and path where you will be hosting these pages into the admob_setcookie() function.

For example, if you are hosting two sites: example.com/Site1 and example.com/Site2 then for the first site call

admob_setcookie('example.com','/Site1');

and for the second site call

admob_setcookie('example.com','/Site2');


Testing & Debugging

Here are some steps that aid in debugging and testing whether AdMob cookies are being set properly in your environment.

  1. Install Mozilla Firefox & run it
  2. Install the Live HTTP Headers add-on or Tamper Data add-on
  3. Restart Firefox
  4. Open the Live HTTP headers/Tamper Data window
  5. Visit your mobile website: http://mobile.mysite.com/
  6. In the Live HTTP Headers/Tamper Data window, you should see the HTTP headers sent from the browser and received from the server.
  • Look for a line that looks such as the following in the HTTP request:
Cookie: ASPSESSIONIDQASCAADQ=ACFPKILDPDHPKKGANKCHIBCC; admobuu=b99172a887e44d64ba6713c1c871bb78
  • Look for a line that looks such as the following in the HTTP response:
Set-Cookie: admobuu=b99172a887e44d64ba6713c1c871bb78; Domain=.mysite.com; Expires=Wed, 28-Feb-2029 20:55:48 GMT; Path=/

If you do not see such lines, then the admobuu cookie is not being set properly.

Personal tools
Documentation