An ad tag is a small piece of code that includes parameters describing the ad space where you want to display ads. For example, when a user is in a screen with an Ad space on your App, the ad tag calls the Ad Server, which replies with a fitting ad in a formated response that your App is able to render.
Hang My Ads supports mobile ad serving in:
Each mobile ad request contains query string parameters, which are essentially key-value pairs that used to target ads to your ad space.
Some of these parameters are required (such as Publisher ID) and others are optional (such as Ads Categories). You can include custom key-value pairs in your mobile ad requests. These custom variables may be based on information about user's interests, a user's registered location, or any other user-specific data.
Typically, when you implement custom variables, you should add them to the end of your ad tag. This way, if the ad tag is truncated for any reason, the optional custom variables will be dropped instead of required parameters.
All mobile ad requests must contain the pub parameter, which specifies the ID of your registration within our platform, and either information about the Ad Space (placement width and height, if it's a phone or a tablet and for example if it's an Android or iOS device) or a Placement ID (parameter placement) if the placement details (for ex: banner space 300x250 in our Android application) are already registred in our system.
You can include additional parameters in your mobile ad requests, including custom variables, so that Hang My Ads Ad Server can more effectively target ads to your ad space. Each mobile ad request contains an ad request URL, which references the ad space to deliver an ad for and various parameters. For example:
https://tracking.hangmytracking.com/ads.php?pub=1775&ad_type=1&w=300&h=250&country=us&os=ios&dev_type=phone&lim=1&res=json
A structured Ad Tag delivery response can be in one of the following formats:
To render ads appropriately in your mobile App or site, your App must configured to interpret the response. If no matching ads are available for a particular ad request, it returns an empty response. You should test a few ad requests to review how Hang My Ads represents objects in its responses and make sure that your App is configured to handle them.
{ "ads": { "count": 1, "ad": [ { "ad_id": "18742", "type": "image", "payout": { "type": "CPI", "amount": 2.45, "currency": "USD" }, "html": "<a href='https://tracking.hangmytracking.com/click.php?oid=12412&aid=1775&adid=18742&subid={CLK_ID}&type=2&ios_ifa={IDFA}' target='_top'> <img src='http://banners.hangmyads.com/files/uploads/Off_A_18742.jpg' height='250' width='300' border='0' alt='Banner 300x250' /></a>\n <div id='beacon_18742_2' style='position: absolute; left: 0px; top: 0px;visibility: hidden;'>\n <img src='https://tracking.hangmytracking.com/prt.php?adid=18742&plid=2' /></div>", "campaign": { "id": "12412", "app": "Hearthstone", "description": "Blizzard’s award-winning card battler – experience the magic, mischief and mayhem with your friends." }, "creative": { "width": "300", "height": "250", "alt": "Banner 300x250", "mime": "image/jpeg", "media_file": "http://banners.hangmyads.com/files/uploads/Off_A_18742.jpg" }, "tracking": { "impression": "https://tracking.hangmytracking.com/prt.php?adid=18742&plid=2", "click": "https://tracking.hangmytracking.com/click.php?oid=12412&aid=1775&adid=18742&subid={CLK_ID}&type=2&ios_ifa={IDFA}" } } ] } }
Each mobile ad request contains parameters, which are essentially key-value pairs that are used to target ads to your ad space. Depending on the type of ad request, some of these parameters are required and others are optional.
Name | Data Type | Description | Required |
---|---|---|---|
pub | Integer | Your publisher ID on HangMyTracking. Contact your account manager if you don't know yours. | Yes |
plid | Integer | The Placement ID created in HMA system. A Placement is a description of the ad space inside your App where an ad is needed. | Yes unless fields with ad space description are used (height, width, device) |
ad_type | Integer | An integer that represents the type of Ad requested. Here are the possible options: 1 - Image Banner 5 - Text Link 7 - Video 8 - Rich Media |
No |
h | Integer | The Height of the Ad Space where an ad is being requested. | Yes if placement ID (plid) is not included |
w | Integer | The Width of the Ad Space where an ad is being requested. | Yes if placement ID (plid) is not include |
os | String | The operating system of the device of the user. Options are: "android" or "ios" | No |
dev_type | String | The type of device this Ad Space is suited for. Options are: "phone" or "tablet" or "both". | No |
country | String | 2 chars Country Code of where the user is at. This will help target the user only suited ad campaigns. | No |
ip | String | The IP of the user internet connection. Only relevant to target ads by location. Not needed if country parameter is being sent. | No |
cat | Integer(s) | Integer or Integers separated by commas, with the category of the ads being requested. The possible options are: 27 - Shopping 29 - Dating 30 - Utilities 31 - Casual Games 32 - Action Games 33 - Card Games 34 - Gambling 35 - Food or Travel |
No |
city | String | The city where the user is at. Usually irrelevant, still can be important for city targeted campaigns. | No |
age | Integer | The age of the user. Only relevant to show the user ads more appealing to his/her age group. | No |
gen | String | The gender of the user. Only relevant to show the user ads more appealing to his/her gender. | No |
lim | String | The maximum number of ads that should be returned in the reply. If you only want one ad returned per request, use lim=1. | No |
res | String | A string with the format of the response. There are 3 options: HTML, JSON, XML. | Yes |
When res=html the request returns a block of HTML code, ready to display in the mobile app, which contains the ad creative, appropriate impression counting beacons, and proper click-tracking elements.
<a href='https://tracking.hangmytracking.com/click.php?oid=12415&aid=1775&adid=18751&subid={CLK_ID}&type=2&ios_ifa={IDFA}' target='_top'>
<img src='http://banners.hangmyads.com/files/uploads/Off_A_18751.jpg' height='250' width='300' border='0' alt='Banner 300x250' />
</a>
<div id='beacon_18751_2' style='position: absolute; left: 0px; top: 0px;visibility: hidden;'>
<img src='https://tracking.hangmytracking.com/prt.php?adid=18751&plid=2' />
</div>
When res=json the request return a JSON enconded response similar to the following example:
{
"ads": {
"count": 1,
"ad": [
{
"ad_id": "18752",
"type": "image",
"payout": {
"type": "CPI",
"amount": 0.84,
"currency": "USD"
},
"html": "<a href='https://tracking.hangmytracking.com/click.php?oid=12415&aid=1775&adid=18752&subid={CLK_ID}&type=2&ios_ifa={IDFA}' target='_top'>\n <img src='http://banners.hangmyads.com/files/uploads/Off_A_18752.jpg' height='250' width='300' border='0' alt='Banner 300x250' /></a>\n <div id='beacon_18752_2' style='position: absolute; left: 0px; top: 0px;visibility: hidden;'>\n <img src='https://tracking.hangmytracking.com/prt.php?adid=18752&plid=2' /></div>",
"campaign": {
"id": "12415",
"app": "MyMobileValues",
"description": "Instant Rewards! Download MyMobileValues and immediately you can enjoy coupons and deals on beauty, home and garden, plus automotive! "
},
"creative": {
"width": "300",
"height": "250",
"alt": "Banner 300x250",
"mime": "image/jpeg",
"media_file": "http://banners.hangmyads.com/files/uploads/Off_A_18752.jpg"
},
"tracking": {
"impression": "https://tracking.hangmytracking.com/prt.php?adid=18752&plid=2",
"click": "https://tracking.hangmytracking.com/click.php?oid=12415&aid=1775&adid=18752&subid={CLK_ID}&type=2&ios_ifa={IDFA}"
}
}
]
}
}
When res=xml the request return a XML formated response similar to the following example:
<ads version="1.0"> <ads> <count>1</count> <ad> <item1> <ad_id>18750</ad_id> <type>image</type> <payout> <type>CPI</type> <amount>0.84</amount> <currency>USD</currency> </payout> <html> <a href='https://tracking.hangmytracking.com/click.php?oid=12415&aid=1775&adid=18750&subid={CLK_ID}&type=2&ios_ifa={IDFA}' target='_top'> <img src='http://banners.hangmyads.com/files/uploads/Off_A_18750.jpg' height='250' width='300' border='0' alt='Banner 300x250' /></a> <div id='beacon_18750_2' style='position: absolute; left: 0px; top: 0px;visibility: hidden;'> <img src='https://tracking.hangmytracking.com/prt.php?adid=18750&plid=2' /></div> </html> <campaign> <id>12415</id> <app>MyMobileValues</app> <description> Instant Rewards! Download MyMobileValues and immediately you can enjoy coupons and deals on beauty, home and garden, plus automotive! </description> </campaign> <creative> <width>300</width> <height>250</height> <alt>Banner 300x250</alt> <mime>image/jpeg</mime> <media_file> http://banners.hangmyads.com/files/uploads/Off_A_18750.jpg </media_file> </creative> <tracking> <impression> https://tracking.hangmytracking.com/prt.php?adid=18750&plid=2 </impression> <click> https://tracking.hangmytracking.com/click.php?oid=12415&aid=1775&adid=18750&subid={CLK_ID}&type=2&ios_ifa={IDFA} </click> </tracking> </item1> </ad> </ads> </ads>
If you are integrated with MoPub and want to run our ads through them, you can run our tags in the Custom JavaScript Networks. Just follow this steps:
<script type="text/javascript">
var hma_pub = PUBLISHER_ID;
var hma_plid = PLACEMENT_ID;
var device_id = '%eudid!';
var hma_ip = '%%IPADDRESS%%';
var bundle = '%%BUNDLE%%';
var cb = '%%CACHEBUSTER%%';
</script>
<script src="https://tracking.hangmytracking.com/js/hma_mopub.min.js"></script>