I know this will vary by era and military force but I'm really interested in all the different ID methods that were used as far back as we know, and how ID was improved upon to get to the point of dog tags.
As a matter of fact, the concept goes a little further back than /u/Orlando1701 suggests:
The Spartans (...) became so eager for battle that, when about to enter the conflict, they wrote their names on little sticks which they fastened to their arms, in order that, if they died, they would not be unidentified by their kinsmen.
-- Diodorus of Sicily, Library of History 8.27.2
Admittedly, Diodorus is a very late source (1st century BC), and we do not know of the Archaic Spartans actually did this. However, it's interesting at least that Diodorus was able to conceive of it. Perhaps he was familiar with the practice from the Romans of his own day.
However, most Ancient Greeks fought as levies along with the other men of their tribe, kinship group, or village; the survivors were expected to identify the dead.
Dog tags or ID tags are a very modern creation basically only dating back to WWI for common use. The Prussian Army was the first to issue them starting around 1870, the British Army started issuing them during WWI. Prior to the modern dog tag bodies of the dead were generally identified based on personal objects found on the body. Often times soldier's in the American Civil War would pin notes inside their uniforms for identification purposes and to function as a last will. The issue of course was that personal objects were often looted after a battle and that paper notes are easily destroyed by sweat, blood, rain, ect... so the number of unidentified in earlier wars was substantially higher than it is in the modern era. Metal tags were far less likely to be damaged. One of the major improvements that 'dog tags' offered was blood typing once transfusions became more common. In the modern U.S. military a trend know as 'meat tags' has become popular with soldiers often times tattooing their name, blood type, gas mask size, ect... to further identification and blood typing.
Drew Faust's This Republic of Suffering is a very comprehensive piece covering death and Civil War - and goes very heavily into depth on attempts at identifying bodies in the aftermath of a battle. If you're interested in the topic I highly suggest it. My response is more Civil War centered, but keep in mind that many of the practices existed elsewhere and continued to be used until much later.
Anyway, as u/Orlando1701 mentioned, personal objects were the most common means by which a body would be identified. Carrying a letter or bible with ones name and hometown was the most preferred method, as these would generally be worthless to looters and likely to be left behind. Of course, there are limitations of using paper in a war environment, as one can imagine.
Another very common route was the identification by a friend. Most of the time a unit was mustered with others from the immediate geographic area, and serving with family or friends was not uncommon. Many times soldiers would make pacts to bury each other if they were killed in combat, and most often some attempt would be made to either mark the grave or send a letter home with a description of the burial site and directions on how to find it on the field. While not foolproof, this did offer families a greater opportunity to recover their dead to be re interred at home.
Unfortunately, in the aftermath of major (Civil War) battles the outcome was generally determined by the routing of enemy forces, and as such the loser rarely had the opportunity to do this. Instead, units assigned to bury their own dead would also be in charge of burying enemy dead. In the aftermath of a major engagement, especially during warmer months, burial details were understandably loathed and done as quickly as possible. This being the case, enemy dead were often placed in mass graves without regard for identifying individual soldiers.
Interestingly, Army regulations stated that commanders had to report all casualties at their earliest convenience; and this was rarely done as an Army on the move simply made it inconvenient. Instead, many independent organizations such as The United States Christian Commission sprang up and made attempts to catalog the war dead, distinguishing characteristics, units, and to send out notifications if possible. Their rolls, while incomplete, helped to identify thousands of dead and wounded on both sides of the war. More still, doctors and nurses often found themselves chronicling last words and names in order to send letters home for those who were under their care - as well as volunteers who would visit the hospitals and transcribe letters. A wonderful example of this is Clara Barton's work with the Office of Correspondence with the Friends of the Missing Men of the U.S. Army. Being endorsed by Lincoln before his death, the Office responded to some 68 thousand letters and helped collect information on some 22 thousand Union soldiers who had been unaccounted for.
There is so much more on the topic, and again I can't stress how well done Faust's work is on the subject.