Adding a query string to menu items determined by the current node? I'm pretty new to Drupal 8.  I'm trying to figure out how to programmatically add a query string to a menu item link, the specific query string is determined by the node/page the user is currently on.

For example, I've got a link on my primary menu that goes to http://www.example.com

If I'm on the 'about me' page I want the link to add a query string of '?origin=about'. (http://www.example.com?origin=about)

If I'm on the 'contact me' page I want the link to add '?origin=contact', etc.

Are there any modules where this can be done, or how might I go about doing this myself?
The menu is cached. You could disable caching and add the query string to the options of the url in hook_link_alter, but this is not good for performance. So this would be better solved in javascript. You can prepare the link in php by setting an attribute, so that you can easily find the link later in the client and attach the query string.