Android Server-to-Server In-App Ad Request

Required Variables

The key to incorporating relevant ads into your application is providing Millennial Media with key values that help identify the device, carrier and country.

####Each of the parameters listed below is required for serving ads.

Parameter Description
APID The Ad Placement ID
AAID * Android Advertising ID
UA User Agent
UIP The User’s Public IP Address

*For devices without Google Play Services 4+, AAID will not be available. In this case, please use the “MMDID” parameter which is the Hashed Android ID.

For more on finding and hashing any of the IDs below, please see finding and hashing IDs under References.

Ad Placement ID (apid)

This value is a unique identifier provided by Millennial Media that needs to be included in every request to provide site metrics back to the Publisher. Without the Placement ID, you will not receive any ad units.

Hashed Android ID (mmdid)

This is the preferred identifier for Android users.

This value that must be passed as the MD5 and SHA-1 hash with “mmh_” appended of to generate a string with the format of mmh_[MD5]_[SHA1].

Example:

...mmdid=mmh_80B2AEF0134242A831D6025B0558BD84_4585EAA5E86BBD2E476320EB1D55E9B1A7BABA4F&..

NOTE: The instructions in finding and hashing IDs will obtain the values in the reqired format.

The Android ID may change if a factory reset is performed on the device. For more information on the Android ID please reference the documentation

User Agent (ua)

This value is used to determine device characteristics.

This value is the UA string of the device browser used to determine the handset making the request. Having the UA enables us to determine certain device characteristics in order to provide the correct ad unit for the request.

In order to determine the UA string of the device browser, we utilize the HTTP_USER_AGENT HTTP header to insert the proper UA string into the ad request.

Note: If you have an internal server in between the handset and this server, you will need to forward the proper UA string into the ad call.

Public IP Address (uip)

This identifier is used to identify the country and carrier of the device.

This value is the Public IP address of the device requesting the ad unit. Private IP addresses on WiFi networks will NOT get identified and thus will not get served ad units.

The integration code provided in the mMedia portal extracts the Public IP address of the device by utilizing the REMOTE_ADDR HTTP header.

Note: If you have an internal server in between the handset and this server, you will need to utilize the X_FORWARDED_FOR HTTP Header in order to obtain the Public IP address of the device.

Provided below is an example of a complete ad request with all the required parameters (Please note the values below are examples only):

...
http://ads.mp.mydas.mobi/getAd?apid=12345&mmdid=mmh_80B2AEF0134242A831D6025B0558BD84_4585EAA5E86BBD2E476320EB1D55E9B1A7BABA4F&ua=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%206_1%20like%20Mac%20OS%20X)%20AppleWebKit%2F536.26%20(KHTML%2C%20like%20Gecko)%20Mobile%2F10B141&uip=38.118.54.10
...

Metadata

Metadata may also be passed during the ad request. To learn more, see Metadata.

For More Information

If you have any questions, please contact us to reach a trained support professional.