you can use accelerometers in your shoes.

It will measure the acceleration of your foot, integrating this gives the speed, integrating the speed gives the distance.

Or easier, it can be used to count the steps you make.

A step is the moment of zero acceleration between acceleration - less math involved - you only need to have some average stepsize.

More accurate but expensive is to use a GPS shield