Adding onclick attribute to menu links I'm trying to add the onclick attribute to some menu links in Drupal 8 in order to track conversions with Google.

Here's a tutorial for adding onclick events in Drupal 7 that uses the Menu Attributes module.

For Drupal 8, I looked at the Link attributes module and the Menu Link attributes module but these only allow you to add classes, not set the value for onclick.
Seems Menu Item Extras is the way to go now. It makes menu items fieldable. And you probably also get the proper template suggestions already.


  Menu Item Extras provides extra fields for the Menu Items without
  using additional entities. This module is NOT an alternative of all
  Mega Menu modules - it is unique implementation of Drupal core’s Menu
  system. All fields are placed upon the Menu Item edit/add form and use
  core Menu link content entity for storing all data.