NBC was already measuring demographics by the mid-1960s, before Star Trek was even on the air. Their appeal among younger audiences even became part of the way NBC marketed itself, with slogans such as "number one network among young adults" appearing during this period.
Indeed, Star Trek was probably renewed after the first season because of it's appeal to younger demographics. Paul Klein, the vice president of research for the network, said as much in both Television magazine and TV Guide in 1967. From the interview in Television, he said, "A quality audience--lots of young adult buyers--provides a high level that may make it worth holding onto a program despite low over-all ratings." In the later TV Guide interview he said that the series was renewed, in spite of poor ratings, "because it delivers a quality, salable audience...[in particular] upper-income, better-educated males."
(I wish I could present this as my research, but it comes from Roberta Pearson's article "Cult Television as Digital Television’s Cutting Edge," published in the recent anthology, "Television as Digital Media.")
Roddenberry's story was that ratings that were broken down by demographics would have saved the show if they had existed in 1969, because the show appealed to a young audience with disposable income that appealed to advertisers. But NBC already had this ratings information, and likely renewed the show for a second and third season because of it. Roddenberry's version is either a lie, or just misinformed.
(He's not the only one to bring up demographics, though; Bob Justman uncritically mentions the myth about them in Inside Star Trek: The Real Story, too)