When Santa Claus asks Mariah Carey if she’s been naughty or nice this year, her performance at last week’s tree-lighting ceremony at Rockefeller Center will undoubtedly be classified in the first category.

After missing the pretaping, Mimi later howled her way through “All I Want for Christmas Is You,” causing much embarrassment all around when it was later aired on NBC.

But she has the chance to redeem herself this week when she plays six festively themed shows at the Beacon Theatre, and the bouncing 1994 single will be a definite highlight.

Twenty years after its release, the song is firmly established as a modern classic. It re-enters Billboard’s Holiday 100 Chart every year and, as Billboard’s associate director of charts/radio Gary Trust reveals, “It’s Carey’s best-selling download of all of her songs — 2.8 million sold since Nielsen Music began tracking sales in the early 2000s.” As of 2013, the song was reported to have earned $50 million in royalties.

“I’ve been very lucky to have written many hits like ‘Hero’ and ‘One Sweet Day’ with Mariah Carey, but ‘All I Want for Christmas Is You’ is the cherry on top,” says Walter Afanasieff, the 56-year-old producer and songwriter who co-wrote the tune. “I never imagined it would be something that we’d still be talking about 20 years later, but I’m glad that we are. It definitely helped feed and clothe my three children!”

We all know the song, but here are eight things you probably didn’t know about how it came together.

1. Carey didn’t even want to record a Christmas album.

At the time, Christmas albums were considered to be for older artists who had been put out to pasture, so the then-24-year-old singer needed convincing from her (now ex-) manager and husband Tommy Mottola.

In his book “Hitmaker: The Man and His Music,” Mottola remembers her seeing the cover of the “Merry Christmas” album (which features Carey on a sleigh) and exclaiming, “What are you trying to do, turn me into Connie Francis?”

“I don’t know what their marriage was like, but Tommy was instrumental in Mariah’s early career milestones,” Afanasieff tells The Post.

2. The song was written in 15 minutes.

When they got together in the summer of 1994 to write songs for the album “Merry Christmas,” Afanasieff and Carey carved out the chords, structure and melody for “All I Want for Christmas Is You” in just a quarter of an hour. “It’s definitely not ‘Swan Lake,’ ” admits Afanasieff. “But that’s why it’s so popular — because it’s so simple and palatable!”

3. The video features a secret cameo.

“All I Want for Christmas Is You” is ostensibly a romantic song, and the object of Carey’s affection makes an appearance in the video she directed — the man dressed up as Santa is none other than Mottola.

4. No actual musicians play on the song.

Although “All I Want for Christmas Is You” sounds like a full band played it, Afanasieff put the song together on his computer. The only things added were the vocals of Carey and her backing singers.

5. Carey made Christmas happen early for the recording.

The vocals for “All I Want for Christmas Is You” were recorded in the dog days of August in New York, but that didn’t stop Carey from getting into the yuletide spirit. “We had Christmas trees and lights brought into the studio to get us in the mood,” laughs Afanasieff. “There was even talk of bringing in some snow at one point, but we didn’t go with that, thank God!”

6. It’s a smash-hit ringtone.

Aside from the worldwide sales that continue to this day, “All I Want for Christmas Is You” has set new records on the cellphone charts. In 2009, it became the first holiday ringtone to be certified double platinum for more than two million sales.

7. Goats love “All I Want for Christmas Is You.”

In 2010, a British goat farmer discovered that his animals produce more milk when Carey’s Christmas classic is played on a loop — in contrast to “The Chipmunk Song (Christmas Don’t Be Late)” by Alvin and the Chipmunks, which reportedly brought milk production to a screeching halt.

“I think Mariah should endorse a brand of Christmas goat cheese made from the milk of those goats,” says Afanasieff. “And I would obviously want half of the profits!”

8. Carey and the song’s co-writer are no longer in contact.

Despite the enduring success of “All I Want for Christmas Is You,” Afanasieff hasn’t heard from Carey since they worked together on 1997’s “Butterfly” album, after which she decided to explore a more R&B-influenced direction.

“It’s a shame, because we had great chemistry,” says Afanasieff. “My greatest dream is to work with her again. Mariah, all I want for Christmas is you!”