Save the data to a database table or json file, as you prefer.
But you need to have the time it was registered and the position in order to trace the route.
You need to set a time interval or distance to be recorded, for example every 5 meters or 1min you save the position.
Example.
The pattern to be followed depends on the need to plot the route... the most commonly used for tracking. is for example: if the position of the distance more than 5 meters, it records the change, remembering that it is necessary to define a radius for tolerance, since q the GPS does not always maintain the accuracy.
In the image posted at all times I was recording the position, so even standing in the same place the GPS returned different values, I did not treat tolerance nor distance from the old position.
In fact, this would be a possibility: initially record a log of each of the coordinates visited, and then perform a post-processing on top of the coordinates.
– Haroldo_OK
If you are using Google Maps, this post lists some of the possibilities: http://stackoverflow.com/questions/17711468/create-a-route-using-a-list-of-coordinates-in-google-maps
– Haroldo_OK