It has to be added to the page where the html link is generated. May not be possible and we’d have to see where the link is generated. Not really an ACF question… but I have a better solution than putting onclick events in your code.
Set up Google Tag Manager on the site. Once you’ve removed your standard GA code and added the Google Tag Manager code you can set up GA and add events to just about anything on the site without mucking about in the code.