The track was written with the help of American Idol viewers throughout Season 11 of the show. The creation of the song was promoted through Coca-Cola's "Perfect Harmony" program where, throughout the season, American Idol viewers were invited to contribute parts of the lyrics to a tune offered online, making the song a true collaborative effort by a big number of people. After four submission and voting phases and thousands of lyric submissions, contributions were edited and the eventual final version performed by Derulo and tipped as part of his "healing process" after he suffered an accident that left him in a neck brace for many months. In an interview with American Idol host Ryan Seacrest on the latter's radio show, Derulo described the writing process as follows: "The fans got to help me write the song. I started writing the song, but I left a bunch of lines blank and the fans have been helping me fill in the lines. There were lots of great, great lines. It made the process a little difficult. Thankfully, I had a lot of help to whittle it down to a number that I could actually look at. There were tons and tons of great stuff, but we got it down and I believe we came up with the best product!"
Derulo performed the song live for the first time on May 22, 2012, during the second final of the American Idol competition. It was later made available for download on the same day. 10,000 free downloads of the song were made available through the official American Idol website. Immediately prior to his live performance, Derulo sent a message via his Twitter account: "First time performing since my neck injury tonight on Idol finale! Thank you to the fans that help[ed] me write this song #UNDEFEATED. It's been two weeks since I took my neck brace off! Still gonna make it happen tonight! NEVER GIVE UP! NEVER LET UP!"