Hi,
Suppose someone request url like https://play.google.com/store/apps/details?id=com.quz.com?ref=12345 (example link)
When anyone request this url, they first need to install application. And after installed, when they opened application the ref value set or store automatically into app.