Friend, the hacking/coughing your dog is experiencing can be caused by many different medical conditions. It will be difficult for me to determine the exact underlying cause without a hands on examination. But, common causes are:
1- An upper respiratory infection.
2- A collapsing trachea: This is when the rings around the trachea (tube connecting mouth to lungs) become weak and collapse.
3- An underlying heart disease: Patients with heart disease will often have a similar cough caused by either fluid accumulation in the lungs or the heart enlarges and places pressure on the thoracic trachea.
4- Other: Lung disease, tumors, foreign body, etc.
The vomiting is common with any of the above conditions, this is a consequence of the forceful hacking. Once the cough is treated and corrected the vomiting will stop.
In this case, I would strongly recommend a hands on examination with family veterinarian to determine the exact underlying cause. In the meantime you can start him on Robitussin DM (cough) 1/2 teaspoon every 8 hours. You can buy Robitussin DM over the counter in any pharmacy.
Please do not forget to rate my answer - I hope you found it to be excellent. If there’s more I can do, please use the reply tab and let me know. It’s my goal to provide you with excellent service." Thank you for your business and I hope to work with you again soon!