How can I add "data-target" additional attribute in mega menu? How can I add an additional attribute to menu item I am using mega menu?

On element inspect my current menu url is displaying as :

&lt;a class="we-mega-menu-li activeNav" title=""href="/clients/drupal/abc/fr/home#xyz" target=""&gt;
 something
&lt;/a&gt;


I need to create it as :

&lt;a class="we-mega-menu-li activeNav" title=""  data-target="xyz" href="/clients/drupal/abc/fr/home#xyz" target=""&gt;
 something
&lt;/a&gt;


I have used menu links attribute module but its not working with mega menu 
any other suggestions by doing some custom code?
You can use below code to set attributes. This will add an attribute to all links in the page. But make sure to add the condition check for your URL.

/**
 * Implements template_preprocess_menu().
 */
function THEME_preprocess_menu(&amp;$variables) {
  foreach ($variables['items'] as $item) {
    $item['attributes']-&gt;setAttribute('data-target', 'YOUR TARGET NAME');
  }
}