Hi, I'm Dr. Peter. Welcome to JustAnswer. I'm reviewing your question now, and will post back with your reply ASAP.
Welcome! Thanks for asking your question, Imogen. My name is***** am a licensed veterinarian and I will be assisting you today. First I need to ask you a few questions so that I can be well informed and give you the best advice.
1- Any pre existing medical conditions?
2- Did he get into anything?
3- Is he lethargic?
4- Can you take a look at his gums and see if they are pink or pale?
Imogen, the hacking you are describing is consistent with an upper respiratory infection. Basically, he has a dog cold. The forceful hacking/gagging is secondary to the inflammation in the upper airway and often will lead to vomiting. This can be caused by viruses or bacteria.
I would recommend a hands-exam with your family veterinarian to auscultate his heart and lungs, he may also need antibiotics. In the meantime, start him on Robitussin DM (cough) 1/2 teaspoon every 6-8 hours for the next week. Limit physical activity (no running) as this will promote the hacking/gagging.
My goal is to provide you with excellent service - I hope I've provided the information you were seeking, if you feel you have received anything less, please reply back as I am happy to address follow-up questions. Kindly rate me when you are done.