(John), of Cowper's famous ballad, is a caricature of Mr. Beyer, an eminent linendraper at the end of Paternoster Row, where it joins Cheapside. He died 1791, at the age of 98. It was Lady Austin who told the adventure to our domestic poet, to divert him from his melancholy. The marriage adventure of Commodore Trunnion in Peregrine Pickle is very similar to the wedding day adventure of John Gilpin.
John Gilpin was a citizen Of credit and renown; A train hand captain eke was he Of famous London town.
Some insist that the “trainband captain” was one Jonathan Gilpin, who died at Bath in 1770, leaving his daughter a legacy of £20,000.
Source: Dictionary of Phrase and Fable, E. Cobham Brewer, 1894
More on Gilpin from Fact Monster: