You can check out Adjust.io, it does exactly that.
If you want to roll it out yourself, for Android you can use any string in the parameter &referrer in the URL to the play store and retrieve it in the app when it first starts.
On iOS you'll have to rely on the IDFA.
EDITED: My initial answer:
The concept of alau.me makes most sense to me here.
It's also not hard to roll this out yourself. Have your own shortlink site where you log the IP address of the user you are going to redirect to the App Store. At the first start of your app you call a web service (or silently send a GET request to a fixed url on your site) where you will again log the IP address.
Combine the data if the time of the web service call is >= 5min (alau.me say they even set that value to 1h) and you know how many customers who used your shortlink actually downloaded and opened the app.