Short snippet that shows how to get url parameters in drupal 8. Where in drupal 7 you would have to do some $_GET or work with args(0), you now have a clean function to do this.
// example.com?tag=1
$tag = \Drupal::request()->query->get('tag');
// Then you can proceed with
if($tag) {
...