Other than getting the titles of his most famous shows correct and the names of his parents and sister right, Yankee Doodle Dandy is a highly fictionalized film about Cohan's life and career. A few of the musical numbers in the film are not even Cohan songs. Many of the dates are not correct. For example, Jerry Cohan passed away in 1917 which was early in George M.'s career. He did not retire for a couple of generations as his wife states in the film. There was only a span of 3 years between Ah, Wilderness! and I'd Rather Be Right.
Nevertheless, it is a very entertaining film.
Cohan's daughter Mary was a consultant on the Broadway musical George M, which is one reason that it is more accurate.