The same as Google Analytics install, except you must use the literal smarty tags or you'll break your gallery.
Example:
{literal} PASTE_PIWIK_CODE_HERE! {/literal}
If you're reading this because you forgot the literal tags in your template so now Gallery2 won't load, go to www.your-example-site.com/gallery-path/lib/support/index.php and clear the template cache, then try again.