Require help - web to iOS application and iTunes link


When I open my project in safari or any other browser specifically in iOS device, there is a button over the website page that says - Click to open the app. Clicking that button will allow the user to open the application straight away, but in case if they don't have the application installed it should ideally open the iTunes, but it shows error.

I'll appreciate any link of instruction. Thanks