The user can also block your tracking scripts. Besides, the user can share the link with friends, and you won't be able to track them this way. I'm sure there are many other reasons why having a middleware is de-facto the industry standard.
Addendum: Yes we know that you think ml/hexbear/grad are tankies and or .world are a bunch of liberals but it gets old quickly. Try and come up with new material.
This is not the place to start flamewars between Lemmy, Mbin and Piefed.
No, it's not the only way. You could track the click with JavaScript.
The user can also block your tracking scripts. Besides, the user can share the link with friends, and you won't be able to track them this way. I'm sure there are many other reasons why having a middleware is de-facto the industry standard.
The user can also block the URL target rewriting. Not sure what's your point though, I said it's not the only way, not that there are better ways.