You can get a badge by completing lessons, passing (or failing) a quiz and/or by completing other activities on the site.