A new method for the analysis of apsidal motions in eclipsing binaries