It is quite known that Lady Gaga has written songs for other other artists.
She wrote "Quicksand" for Britney Spears; contributed "Fever" to Lambert's album For Your Entertainment; she was a co-writer of "Elevator" by Pussycat Dolls, "Full Service" by New Kids on the Block and rapper Wale's 2009 song "Chillin".
And while a number of sources have confirmed that Gaga has written a song for Fergie, it's unclear and virtually hard to find what that specific song was.
See list of songs performed by Fergie at Metrolyrics.com.
Of interest, check out these 20 instances of smash songs originally intended for other artists, featured at Billboard.com.