1page.title=Google Play Badges 2@jd:body 3 4<p itemprop="description">Google Play badges allow you to promote your app with official branding 5in your online ads, promotional materials, or anywhere else you want a link to your app.</p> 6 7<p>In the form below, 8input your app's package name or publisher name, choose the badge style, 9click <em>Build my badge</em>, then paste the HTML into your web content.</p> 10 11<p>If you're creating a promotional web page for your app, you should also use the 12<a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly 13wraps your screenshots in real device artwork.</p> 14 15<p>For guidelines when using the Google Play badge and other brand assets, 16see the <a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand 17Guidelines</a>.</p> 18 19<style type="text/css"> 20 21form.button-form { 22 margin-top:2em; 23} 24 25/* the label and input elements are blocks that float left in order to 26 keep the left edgets of the input aligned, and IE 6/7 do not fully support "inline-block" */ 27label.block { 28 display: block; 29 float: left; 30 width: 100px; 31 padding-right: 10px; 32} 33 34input.text { 35 display: block; 36 float: left; 37 width: 250px; 38} 39 40div.button-row { 41 white-space:nowrap; 42 min-height:80px; 43} 44 45div.button-row input { 46 vertical-align:middle; 47 margin:0 5px 0 0; 48} 49 50#jd-content div.button-row img { 51 margin: 0; 52 vertical-align:middle; 53} 54 55</style> 56 57<script type="text/javascript"> 58 59// locales for which we have the 'app' badge 60var APP_LANGS = ['it','pt-br','pt-pt','nl','ko','ja','fr','es','es-419','en','de']; 61 62// variables for creating 'try it out' demo button 63var imagePath = "https://developer.android.com/images/brand/" 64var linkStart = "<a href=\"https://play.google.com/store/"; 65var imageStart = "\">\n" 66 + " <img alt=\""; 67 // leaves opening for the alt text value 68var imageSrc = "\"\n src=\"" + imagePath; 69 // leaves opening for the image file name 70var imageEnd = ".png\" />\n</a>"; 71 72// variables for creating code snippet 73var linkStartCode = "<a href=\"https://play.google.com/store/"; 74var imageStartCode = "\">\n" 75 + " <img alt=\""; 76 // leaves opening for the alt text value 77var imageSrcCode = "\"\n src=\"" + imagePath; 78 // leaves opening for the image file name 79var imageEndCode = ".png\" />\n</a>"; 80 81/** Generate the HTML snippet and demo based on form values */ 82function buildButton(form) { 83 var lang = $('#locale option:selected').val(); 84 var selectedValue = lang + $('form input[type=radio]:checked').val(); 85 var altText = selectedValue.indexOf("generic") != -1 ? "Get it on Google Play" : "Android app on Google Play"; 86 87 if (form["package"].value != "com.example.android") { 88 $("#preview").show(); 89 var packageName = escapeHTML(form["package"].value); 90 $("#snippet").show().html(linkStartCode + "apps/details?id=" + packageName 91 + imageStartCode + altText + imageSrcCode 92 + selectedValue + imageEndCode); 93 $("#button-preview").html(linkStart + "apps/details?id=" + packageName 94 + imageStart + altText + imageSrc 95 + selectedValue + imageEnd); 96 97 // Send the event to Analytics 98 _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]); 99 } else if (form["publisher"].value != "Example, Inc.") { 100 $("#preview").show(); 101 var publisherName = escapeHTML(form["publisher"].value); 102 $("#snippet").show().html(linkStartCode + "search?q=pub:" + publisherName 103 + imageStartCode + altText + imageSrcCode 104 + selectedValue + imageEndCode); 105 $("#button-preview").html(linkStart + "search?q=pub:" + publisherName 106 + imageStart + altText + imageSrc 107 + selectedValue + imageEnd); 108 109 // Send the event to Analytics 110 _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue]); 111 } else { 112 alert("Please enter your package name or publisher name"); 113 } 114 return false; 115} 116 117/** Listen for Enter key */ 118function onTextEntered(event, form, me) { 119 // 13 = enter 120 if (event.keyCode == 13) { 121 buildButton(form); 122 } 123} 124 125/** When input is focused, remove example text and disable other input */ 126function onInputFocus(object, example) { 127 if (object.value == example) { 128 $(object).val('').css({'color' : '#000'}); 129 } 130 $('input[type="text"]:not(input[name='+object.name+'])', 131 object.parentNode).attr('disabled','true'); 132 $('#'+object.name+'-clear').show(); 133} 134 135/** When input is blured, restore example text if appropriate and enable other input */ 136function onInputBlur(object, example) { 137 if (object.value.length < 1) { 138 $(object).attr('value',example).css({'color':'#ccc'}); 139 $('input[type="text"]', object.parentNode).removeAttr('disabled'); 140 $('#'+object.name+'-clear').hide(); 141 } 142} 143 144/** Clear the form to start over */ 145function clearLabel(id, example) { 146 $("#preview").hide(); 147 $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'}); 148 $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled'); 149 $('#'+id+'-clear').hide(); 150 return false; 151} 152 153/** Switch the badge urls for selected language */ 154function changeBadgeLang() { 155 var lang = $('#locale option:selected').val(); 156 157 // check if we have the 'app' badge for this lang and show notice if not 158 $("div.button-row.error").remove(); // remove any existing instance of error message 159 if ($.inArray(lang,APP_LANGS) == -1) { 160 $("div.button-row.app").hide(); 161 $("div.button-row.app").after('<div class="button-row error"><p class="note" style="margin:1em 0 -1em">' 162 + 'Sorry, we currently don\'t have the ' 163 + '<em>Android app on Google Play</em> badge translated for ' 164 + $("select#locale option[value="+lang+"]").attr("title") 165 + '.<br>Please check back later or instead use the <em>Get it on Google Play</em> badge below.' 166 + '</p></div>'); 167 } else { 168 $("div.button-row.app").show(); // show the 'app' badge row 169 } 170 171 $('.button-row img').each(function() { 172 var id = $(this).parent().attr('for'); 173 var imgName = lang + $('input#'+id).attr('value') + '.png'; 174 var lastSlash = $(this).attr('src').lastIndexOf('/'); 175 var imgPath = $(this).attr('src').substring(0, lastSlash+1); 176 $(this).attr('src', imgPath + imgName); 177 }); 178} 179 180/** When the doc is ready, find the inputs and color the input grey if the value is the example 181 text. This is necessary to handle back-navigation, which can auto-fill the form with previous 182 values (and text should not be grey) */ 183$(document).ready(function() { 184 $(".button-form input.text").each(function(index) { 185 if ($(this).val() == $(this).attr("default")) { 186 $(this).css("color","#ccc"); 187 } else { 188 /* This is necessary to handle back-navigation to the page after form was filled */ 189 $('input[type="text"]:not(input[name='+this.name+'])', 190 this.parentNode).attr('disabled','true'); 191 $('#'+this.name+'-clear').show(); 192 } 193 }); 194}); 195 196</script> 197 198<form class="button-form"> 199 <label class="block" for="locale">Language:</label> 200 <select id="locale" style="display:block;float:left;margin:0" 201 onchange="changeBadgeLang()"> 202 <option title="Afrikaans" 203 value="af">Afrikaans</option> 204<!-- 205 <option title="Arabic" 206 value="ar">العربية</option> 207--> 208 <option title="Belarusian" 209 value="be">Беларуская</option> 210 <option title="Bulgarian" 211 value="bg">Български</option> 212 <option title="Catalan" 213 value="ca">Català</option> 214 <option title="Chinese (China)" 215 value="zh-cn">中文 (中国)</option> 216 <option title="Chinese (Hong Kong)" 217 value="zh-hk">中文(香港)</option> 218 <option title="Chinese (Taiwan)" 219 value="zh-tw">中文 (台灣)</option> 220 <option title="Croatian" 221 value="hr">Hrvatski</option> 222 <option title="Czech" 223 value="cs">Česky</option> 224 <option title="Danish" 225 value="da">Dansk</option> 226 <option title="Dutch" 227 value="nl">Nederlands</option> 228 <option title="Estonian" 229 value="et">Eesti</option> 230 <option title="Farsi - Persian" 231 value="fa">فارسی</option> 232 <option title="Filipino" 233 value="fil">Tagalog</option> 234 <option title="Finnish" 235 value="fi">Suomi</option> 236 <option title="French" 237 value="fr">Français</option> 238 <option title="German" 239 value="de">Deutsch</option> 240 <option title="Greek" 241 value="el">Ελληνικά</option> 242 <option title="English" 243 value="en" selected="true">English</option> 244<!-- 245 <option title="Hebrew" 246 value="iw-he">עברית</option> 247--> 248 <option title="Hungarian" 249 value="hu">Magyar</option> 250 <option title="Indonesian" 251 value="id-in">Bahasa Indonesia</option> 252 <option title="Italian" 253 value="it">Italiano</option> 254 <option title="Japanese" 255 value="ja">日本語</option> 256 <option title="Korean" 257 value="ko">한국어</option> 258 <option title="Latvian" 259 value="lv">Latviešu</option> 260 <option title="Lithuanian" 261 value="lt">Lietuviškai</option> 262 <option title="Malay" 263 value="ms">Bahasa Melayu</option> 264 <option title="Norwegian" 265 value="no">Norsk (bokmål)</option> 266 <option title="Polish" 267 value="pl">Polski</option> 268 <option title="Portuguese (Brazil)" 269 value="pt-br">Português (Brasil)</option> 270 <option title="Portuguese (Portugal)" 271 value="pt-pt">Português (Portugal)</option> 272 <option title="Romanian" 273 value="ro">Română</option> 274 <option title="Russian" 275 value="ru">Русский</option> 276 <option title="Serbian" 277 value="sr">Српски / srpski</option> 278 <option title="Slovak" 279 value="sk">Slovenčina</option> 280 <option title="Slovenian" 281 value="sl">Slovenščina</option> 282 <option title="Spanish (Spain)" 283 value="es">Español (España)</option> 284 <option title="Spanish (Latin America)" 285 value="es-419">Español (Latinoamérica)</option> 286 <option title="Swedish" 287 value="sv">Svenska</option> 288 <option title="Swahili" 289 value="sw">Kiswahili</option> 290 <option title="Thai" 291 value="th">ไทย</option> 292 <option title="Turkish" 293 value="tr">Türkçe</option> 294 <option title="Ukrainian" 295 value="uk">Українська</option> 296 <option title="Vietnamese" 297 value="vi">Tiếng Việt</option> 298 <option title="Zulu" 299 value="zu">isiZulu</option> 300 </select> 301 <p style="clear:both;margin:0"> </p> 302 <label class="block" for="package" style="clear:left">Package name:</label> 303 <input class="text" type="text" id="package" name="package" 304 value="com.example.android" 305 default="com.example.android" 306 onfocus="onInputFocus(this, 'com.example.android')" 307 onblur="onInputBlur(this, 'com.example.android')" 308 onkeyup="return onTextEntered(event, this.parentNode, this)"/> 309 <a id="package-clear" style="display:none" href="#" 310 onclick="return clearLabel('package','com.example.android');">clear</a> 311 <p style="clear:both;margin:0"> <em>or</em></p> 312 <label class="block" style="margin-top:5px" for="publisher">Publisher name:</label> 313 <input class="text" type="text" id="publisher" name="publisher" 314 value="Example, Inc." 315 default="Example, Inc." 316 onfocus="onInputFocus(this, 'Example, Inc.')" 317 onblur="onInputBlur(this, 'Example, Inc.')" 318 onkeyup="return onTextEntered(event, this.parentNode, this)"/> 319 <a id="publisher-clear" style="display:none" href="#" 320 onclick="return clearLabel('publisher','Example, Inc.');">clear</a> 321 <br/><br/> 322 323 324<div class="button-row app"> 325 <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" /> 326 <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png" 327alt="Android app on Google Play (small)" /></label> 328 329 <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" /> 330 <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" 331alt="Android app on Google Play (large)" /></label> 332</div> 333 334<div class="button-row"> 335 <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="checked" /> 336 <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png" 337alt="Get it on Google Play (small)" /></label> 338 339 <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" /> 340 <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" 341alt="Get it on Google Play (large)" /></label> 342</div> 343 344 <input class="button" onclick="return buildButton(this.parentNode);" 345 type="button" value="Build my badge" style="padding:10px" /> 346 <br/> 347</form> 348 349<div id="preview" style="display:none"> 350 <p>Copy and paste this HTML into your web site:</p> 351 <textarea id="snippet" cols="100" rows="5" onclick="this.select()" 352style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em"> 353 </textarea > 354 355<p>Try it out:</p> 356<div id="button-preview" style="margin-top:1em"></div> 357</div> 358