Her symptoms sound very much like she has kennel cough or canine cough. A dry cough that can end with a gagging sound at the end. No other symptoms are generally apparent in the beginning of the illness however left untreated, this can turn into pneumonia.
This is an airborne virus that is very contagious to other dogs. She may have caught this from being around other dogs. Even if she is vaccinated against "bordetella" the vaccination is not able to protect her 100% because of the many strains. (similar to our flu virus)
She will need to be examined and treated by your vet at your earliest convenience. One other thought - is she is a small or toy breed dog, she may have problems with her trachea which can produce the same symptom. Especially is she wears a collar and pulls alot on a leash, or this cough is present after exercise or excitement. If this is the case, your vet still needs to examine her and you should change from a collar to a harness.
I wish you the best of luck with your pooch and hope all is well in a very short time!
Please reply to any questions or let me know if you need further assistance!Otherwise, I hope you have found this answer satsifactory and worth acceptance!
Oliver's Mom