Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 1 | page.title=Google Play Badges |
| 2 | @jd:body |
| 3 | |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 4 | <p>Google Play badges allow you to promote your app with official branding in your |
| 5 | online ads, promotional materials, or anywhere else you want a link to your app.</p> |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 6 | |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 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> |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 10 | |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 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, |
Scott Main | d401d58 | 2012-09-17 22:08:57 -0700 | [diff] [blame] | 16 | see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 17 | Guidelines</a>.</p> |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 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 { |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 46 | vertical-align:middle; |
| 47 | margin:0 5px 0 0; |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | #jd-content div.button-row img { |
| 51 | margin: 0; |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 52 | vertical-align:middle; |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | </style> |
| 56 | |
| 57 | <script type="text/javascript"> |
| 58 | |
| 59 | // variables for creating 'try it out' demo button |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 60 | var imagePath = "http://developer.android.com/images/brand/" |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 61 | var linkStart = "<a href=\"http://play.google.com/store/"; |
| 62 | var imageStart = "\">\n" |
| 63 | + " <img alt=\""; |
| 64 | // leaves opening for the alt text value |
| 65 | var imageSrc = "\"\n src=\"" + imagePath; |
| 66 | // leaves opening for the image file name |
| 67 | var imageEnd = ".png\" />\n</a>"; |
| 68 | |
| 69 | // variables for creating code snippet |
| 70 | var linkStartCode = "<a href=\"http://play.google.com/store/"; |
| 71 | var imageStartCode = "\">\n" |
| 72 | + " <img alt=\""; |
| 73 | // leaves opening for the alt text value |
| 74 | var imageSrcCode = "\"\n src=\"" + imagePath; |
| 75 | // leaves opening for the image file name |
| 76 | var imageEndCode = ".png\" />\n</a>"; |
| 77 | |
| 78 | /** Generate the HTML snippet and demo based on form values */ |
| 79 | function buildButton(form) { |
| 80 | var selectedValue = $('form input[type=radio]:checked').val(); |
| 81 | var altText = selectedValue.indexOf("get_it") != -1 ? "Get it on Google Play" : "Android app on Google Play"; |
| 82 | |
| 83 | if (form["package"].value != "com.example.android") { |
| 84 | $("#preview").show(); |
| 85 | $("#snippet").show().html(linkStartCode + "apps/details?id=" + form["package"].value |
| 86 | + imageStartCode + altText + imageSrcCode |
| 87 | + selectedValue + imageEndCode); |
| 88 | $("#button-preview").html(linkStart + "apps/details?id=" + form["package"].value |
| 89 | + imageStart + altText + imageSrc |
| 90 | + selectedValue + imageEnd); |
Scott Main | fe3057f | 2012-10-03 15:23:06 -0700 | [diff] [blame] | 91 | |
| 92 | // Send the event to Analytics |
| 93 | _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]); |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 94 | } else if (form["publisher"].value != "Example, Inc.") { |
| 95 | $("#preview").show(); |
| 96 | $("#snippet").show().html(linkStartCode + "search?q=pub:" + form["publisher"].value |
| 97 | + imageStartCode + altText + imageSrcCode |
| 98 | + selectedValue + imageEndCode); |
| 99 | $("#button-preview").html(linkStart + "search?q=pub:" + form["publisher"].value |
| 100 | + imageStart + altText + imageSrc |
| 101 | + selectedValue + imageEnd); |
Scott Main | fe3057f | 2012-10-03 15:23:06 -0700 | [diff] [blame] | 102 | |
| 103 | // Send the event to Analytics |
| 104 | _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue]); |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 105 | } else { |
| 106 | alert("Please enter your package name or publisher name"); |
| 107 | } |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | /** Listen for Enter key */ |
| 112 | function onTextEntered(event, form, me) { |
| 113 | // 13 = enter |
| 114 | if (event.keyCode == 13) { |
| 115 | buildButton(form); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** When input is focused, remove example text and disable other input */ |
| 120 | function onInputFocus(object, example) { |
| 121 | if (object.value == example) { |
| 122 | $(object).val('').css({'color' : '#000'}); |
| 123 | } |
| 124 | $('input[type="text"]:not(input[name='+object.name+'])', |
| 125 | object.parentNode).attr('disabled','true'); |
| 126 | $('#'+object.name+'-clear').show(); |
| 127 | } |
| 128 | |
| 129 | /** When input is blured, restore example text if appropriate and enable other input */ |
| 130 | function onInputBlur(object, example) { |
| 131 | if (object.value.length < 1) { |
| 132 | $(object).attr('value',example).css({'color':'#ccc'}); |
| 133 | $('input[type="text"]', object.parentNode).removeAttr('disabled'); |
| 134 | $('#'+object.name+'-clear').hide(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** Clear the form to start over */ |
| 139 | function clearLabel(id, example) { |
| 140 | $("#preview").hide(); |
| 141 | $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'}); |
| 142 | $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled'); |
| 143 | $('#'+id+'-clear').hide(); |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | /** When the doc is ready, find the inputs and color the input grey if the value is the example |
| 148 | text. This is necessary to handle back-navigation, which can auto-fill the form with previous |
| 149 | values (and text should not be grey) */ |
| 150 | $(document).ready(function() { |
| 151 | $(".button-form input.text").each(function(index) { |
| 152 | if ($(this).val() == $(this).attr("default")) { |
| 153 | $(this).css("color","#ccc"); |
| 154 | } else { |
| 155 | /* This is necessary to handle back-navigation to the page after form was filled */ |
| 156 | $('input[type="text"]:not(input[name='+this.name+'])', |
| 157 | this.parentNode).attr('disabled','true'); |
| 158 | $('#'+this.name+'-clear').show(); |
| 159 | } |
| 160 | }); |
| 161 | }); |
| 162 | |
| 163 | </script> |
| 164 | |
| 165 | <form class="button-form"> |
| 166 | <label class="block" for="package">Package name:</label> |
| 167 | <input class="text" type="text" id="package" name="package" |
| 168 | value="com.example.android" |
| 169 | default="com.example.android" |
| 170 | onfocus="onInputFocus(this, 'com.example.android')" |
| 171 | onblur="onInputBlur(this, 'com.example.android')" |
| 172 | onkeyup="return onTextEntered(event, this.parentNode, this)"/> |
| 173 | <a id="package-clear" style="display:none" href="#" |
| 174 | onclick="return clearLabel('package','com.example.android');">clear</a> |
| 175 | <p style="clear:both;margin:0"> <em>or</em></p> |
| 176 | <label class="block" style="margin-top:5px" for="publisher">Publisher name:</label> |
| 177 | <input class="text" type="text" id="publisher" name="publisher" |
| 178 | value="Example, Inc." |
| 179 | default="Example, Inc." |
| 180 | onfocus="onInputFocus(this, 'Example, Inc.')" |
| 181 | onblur="onInputBlur(this, 'Example, Inc.')" |
| 182 | onkeyup="return onTextEntered(event, this.parentNode, this)"/> |
| 183 | <a id="publisher-clear" style="display:none" href="#" |
| 184 | onclick="return clearLabel('publisher','Example, Inc.');">clear</a> |
| 185 | <br/><br/> |
| 186 | |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 187 | |
| 188 | <div class="button-row"> |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 189 | <input type="radio" name="buttonStyle" value="en_app_rgb_wo_45" id="ws" checked="checked" /> |
| 190 | <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png" |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 191 | alt="Android app on Google Play (small)" /></label> |
| 192 | |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 193 | <input type="radio" name="buttonStyle" value="en_app_rgb_wo_60" id="wm" /> |
| 194 | <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 195 | alt="Android app on Google Play (large)" /></label> |
| 196 | </div> |
| 197 | |
Scott Main | 4420402 | 2012-09-13 14:52:03 -0700 | [diff] [blame] | 198 | <div class="button-row"> |
| 199 | <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_45" id="ns" /> |
| 200 | <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png" |
| 201 | alt="Get it on Google Play (small)" /></label> |
| 202 | |
| 203 | <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_60" id="nm" /> |
| 204 | <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" |
| 205 | alt="Get it on Google Play (large)" /></label> |
| 206 | </div> |
| 207 | |
Scott Main | fe3057f | 2012-10-03 15:23:06 -0700 | [diff] [blame] | 208 | <input onclick="return buildButton(this.parentNode);" |
Scott Main | 48b2cad | 2012-10-03 17:23:45 -0700 | [diff] [blame] | 209 | type="button" value="Build my badge" style="padding:10px" /> |
Scott Main | 50e990c | 2012-06-21 17:14:39 -0700 | [diff] [blame] | 210 | <br/> |
| 211 | </form> |
| 212 | |
| 213 | <div id="preview" style="display:none"> |
| 214 | <p>Copy and paste this HTML into your web site:</p> |
| 215 | <textarea id="snippet" cols="100" rows="5" onclick="this.select()" |
| 216 | style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em"> |
| 217 | </textarea > |
| 218 | |
| 219 | <p>Try it out:</p> |
| 220 | <div id="button-preview" style="margin-top:1em"></div> |
| 221 | </div> |