Below would be the pure Javascript way to do what have you requested.
document.querySelector("a[class^='link']").addEventListener('click',function(ev){
var index = this.attributes['key'].value;
var link_name = "click_visit_link"+index;
ga('send', 'event', 'button', 'visit', link_name);
var href = this.attributes['href'].value
window.open(href, '_self');
return false;
});
Please note that it's better to design a generic event listener like listed above, rather than create a event listener separately for all such links on your page. (You might have 10 now, but they can increase in future. You don't want to write same piece of code again & again).
document.querySelector("a[class*='link']")
This line would basically select all anchor elements that has a class associated with it and starting with 'list'.
Once you have all such elements, it's simple to add event listener to all such elements via addEventListener function of Javascript.
document.querySelector("a[class^='link']").addEventListener('click',function(ev){
Inside the listener function, you can get index of selected elements in multiple ways. I have demoed it using an extra attribute on each link element viz. 'key'.
var index = this.attributes['key'].value;
var link_name = "click_visit_link"+index;
ga('send', 'event', 'button', 'visit', link_name);
Basically, you read the link index from key attribute and use it to create the custom event text to be sent to Google Analytics and then read href attribute to open up the link.
You can explore another ways to retrieve the index as well.
Below JS Fiddle might be helpful to play around with.
https://jsfiddle.net/cfy4yw5s/