Home | History | Annotate | Download | only in promote
      1 page.title=Google Play Badges
      2 @jd:body
      3 
      4 <p itemprop="description">Google Play badges allow you to promote your app with official branding
      5 in your online ads, promotional materials, or anywhere else you want a link to your app.</p>
      6 
      7 <p>In the form below,
      8 input your app's package name or publisher name, choose the badge style,
      9 click <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
     13 wraps your screenshots in real device artwork.</p>
     14 
     15 <p>For guidelines when using the Google Play badge and other brand assets,
     16 see the <a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand
     17 Guidelines</a>.</p>
     18 
     19 <style type="text/css">
     20 
     21 form.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" */
     27 label.block {
     28   display: block;
     29   float: left;
     30   width: 100px;
     31   padding-right: 10px;
     32 }
     33 
     34 input.text {
     35   display: block;
     36   float: left;
     37   width: 250px;
     38 }
     39 
     40 div.button-row {
     41   white-space:nowrap;
     42   min-height:80px;
     43 }
     44 
     45 div.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
     60 var 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
     63 var imagePath = "https://developer.android.com/images/brand/"
     64 var linkStart = "<a href=\"https://play.google.com/store/";
     65 var imageStart = "\">\n"
     66         + "  <img alt=\"";
     67   // leaves opening for the alt text value
     68 var imageSrc = "\"\n       src=\"" + imagePath;
     69   // leaves opening for the image file name
     70 var imageEnd = ".png\" />\n</a>";
     71 
     72 // variables for creating code snippet
     73 var linkStartCode = "&lt;a href=\"https://play.google.com/store/";
     74 var imageStartCode = "\"&gt;\n"
     75         + "  &lt;img alt=\"";
     76   // leaves opening for the alt text value
     77 var imageSrcCode = "\"\n       src=\"" + imagePath;
     78   // leaves opening for the image file name
     79 var imageEndCode = ".png\" />\n&lt;/a>";
     80 
     81 /** Generate the HTML snippet and demo based on form values */
     82 function 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 */
    118 function 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 */
    126 function 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 */
    136 function 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 */
    145 function 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 */
    154 function 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     <option title="Arabic"
    205             value="ar"></option>
    206     <option title="Belarusian"
    207             value="be"></option>
    208     <option title="Bulgarian"
    209             value="bg"></option>
    210     <option title="Catalan"
    211             value="ca">Catal</option>
    212     <option title="Chinese (China)"
    213             value="zh-cn"> ()</option>
    214     <option title="Chinese (Hong Kong)"
    215             value="zh-hk"></option>
    216     <option title="Chinese (Taiwan)"
    217             value="zh-tw"> ()</option>
    218     <option title="Croatian"
    219             value="hr">Hrvatski</option>
    220     <option title="Czech"
    221             value="cs">esky</option>
    222     <option title="Danish"
    223             value="da">Dansk</option>
    224     <option title="Dutch"
    225             value="nl">Nederlands</option>
    226     <option title="Estonian"
    227             value="et">Eesti</option>
    228     <option title="Farsi - Persian"
    229             value="fa"></option>
    230     <option title="Filipino"
    231             value="fil">Tagalog</option>
    232     <option title="Finnish"
    233             value="fi">Suomi</option>
    234     <option title="French"
    235             value="fr">Franais</option>
    236     <option title="German"
    237             value="de">Deutsch</option>
    238     <option title="Greek"
    239             value="el"></option>
    240     <option title="English"
    241             value="en" selected="true">English</option>
    242 <!--
    243     <option title="Hebrew"
    244             value="iw-he"></option>
    245 -->
    246     <option title="Hungarian"
    247             value="hu">Magyar</option>
    248     <option title="Indonesian"
    249             value="id-in">Bahasa Indonesia</option>
    250     <option title="Italian"
    251             value="it">Italiano</option>
    252     <option title="Japanese"
    253             value="ja"></option>
    254     <option title="Korean"
    255             value="ko"></option>
    256     <option title="Latvian"
    257             value="lv">Latvieu</option>
    258     <option title="Lithuanian"
    259             value="lt">Lietuvikai</option>
    260     <option title="Malay"
    261             value="ms">Bahasa Melayu</option>
    262     <option title="Norwegian"
    263             value="no">Norsk (bokml)</option>
    264     <option title="Polish"
    265             value="pl">Polski</option>
    266     <option title="Portuguese (Brazil)"
    267             value="pt-br">Portugus (Brasil)</option>
    268     <option title="Portuguese (Portugal)"
    269             value="pt-pt">Portugus (Portugal)</option>
    270     <option title="Romanian"
    271             value="ro">Romn</option>
    272     <option title="Russian"
    273             value="ru"></option>
    274     <option title="Serbian"
    275             value="sr"> / srpski</option>
    276     <option title="Slovak"
    277             value="sk">Slovenina</option>
    278     <option title="Slovenian"
    279             value="sl">Slovenina</option>
    280     <option title="Spanish (Spain)"
    281             value="es">Espaol (Espaa)</option>
    282     <option title="Spanish (Latin America)"
    283             value="es-419">Espaol (Latinoamrica)</option>
    284     <option title="Swedish"
    285             value="sv">Svenska</option>
    286     <option title="Swahili"
    287             value="sw">Kiswahili</option>
    288     <option title="Thai"
    289             value="th"></option>
    290     <option title="Turkish"
    291             value="tr">Trke</option>
    292     <option title="Ukrainian"
    293             value="uk"></option>
    294     <option title="Vietnamese"
    295             value="vi">Ting Vit</option>
    296     <option title="Zulu"
    297             value="zu">isiZulu</option>
    298   </select>
    299   <p style="clear:both;margin:0">&nbsp;</p>
    300   <label class="block" for="package" style="clear:left">Package name:</label>
    301   <input class="text" type="text" id="package" name="package"
    302          value="com.example.android"
    303          default="com.example.android"
    304          onfocus="onInputFocus(this, 'com.example.android')"
    305          onblur="onInputBlur(this, 'com.example.android')"
    306          onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
    307          <a id="package-clear" style="display:none" href="#"
    308             onclick="return clearLabel('package','com.example.android');">clear</a>
    309   <p style="clear:both;margin:0">&nbsp;<em>or</em></p>
    310   <label class="block" style="margin-top:5px" for="publisher">Publisher&nbsp;name:</label>
    311   <input class="text" type="text" id="publisher" name="publisher"
    312          value="Example, Inc."
    313          default="Example, Inc."
    314          onfocus="onInputFocus(this, 'Example, Inc.')"
    315          onblur="onInputBlur(this, 'Example, Inc.')"
    316          onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
    317          <a id="publisher-clear" style="display:none" href="#"
    318             onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
    319          <br/><br/>
    320 
    321 
    322 <div class="button-row app">
    323   <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" />
    324     <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
    325 alt="Android app on Google Play (small)" /></label>
    326     &nbsp;&nbsp;&nbsp;&nbsp;
    327   <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" />
    328     <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
    329 alt="Android app on Google Play (large)" /></label>
    330 </div>
    331 
    332 <div class="button-row">
    333   <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="checked" />
    334     <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
    335 alt="Get it on Google Play (small)" /></label>
    336     &nbsp;&nbsp;&nbsp;&nbsp;
    337   <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" />
    338     <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
    339 alt="Get it on Google Play (large)" /></label>
    340 </div>
    341 
    342   <input class="button" onclick="return buildButton(this.parentNode);"
    343     type="button" value="Build my badge" style="padding:10px" />
    344   <br/>
    345 </form>
    346 
    347 <div id="preview" style="display:none">
    348   <p>Copy and paste this HTML into your web site:</p>
    349   <textarea id="snippet" cols="100" rows="5" onclick="this.select()"
    350 style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em">
    351   </textarea >
    352 
    353 <p>Try it out:</p>
    354 <div id="button-preview" style="margin-top:1em"></div>
    355 </div>
    356