First, you'll need to define what you mean by "distance traveled". For example, let's assume we have 2 points that are 10 units apart (pointA and pointB). If the player moved from pointA to pointB (in a straight line), they've obviously moved 10 units. However, what if the player moves from pointA to pointB and then back to pointA. Is that 20 units or 0 units? I assume 20 units, but your answer will impact how you go about coding for this.
Really, this is about continuously calculating the distance between 2 points - you just need to decide on the proper sampling rate or trigger. Some examples:
You could simply have a timer that fires at regular intervals (say, every second or so). When the timer fires, you could calculate the distance between the player's current point and their previous point (when the timer fired last time) and add it to your running "total distance". That'd be really easy, and if your sample rate is high enough, it'd be relatively accurate. Obviously, it'd miss minor overlapped movements that happened between intervals.
Another way might be motion based. Each frame you're somehow (already) calculating how far to move the player based on input events. Once that value is known, use it not only to move the player, but also add it to the running total. This would also be easy and should be very accurate.
To get more specific input (such as code suggestions), I'd suggest that you share your current movement code, as that second idea will likely need to be integrated there...