The scratch test is a very powerful technique for measuring hardness at very shallow penetration depths. In the present work, the scratching protocol and data analysis were extended by combining the initial surface profile, the instrument compliance, thermal drift and indenter displacement during the test, which allows reconstruction of the complete indenter trajectory during the scratch test. The analysis of such a diagram leads to the in situ estimation of pile-up sizes and their influence on the area of contact between the indenter and the material. As a result, criteria for a scratch width estimation algorithm can be formalized as well as scratching contact depth can be derived. Based on the indenter apex shape characterized with scanning probe microscopy, it has been shown that lateral elastic recovery takes place during the scratch test. The proposed analysis was applied to the measurement of scratch hardness for several materials known for different piling and elastic recovery behavior during mechanical testing.