 " Piece of Me " was co @-@ written and produced by the Swedish duo Christian Karlsson and Pontus Winnberg , professionally known as Bloodshy & Avant , along with Klas Åhlund . While recording with Spears over the years , Karlsson and Winnberg often saw first @-@ hand how her regular activities were interrupted by the paparazzi , including one experience in Hamburg which Winnberg deemed as " really scary " . For Blackout , Spears worked with them on " Radar " , " Freakshow " and " Toy Soldier " . When the album was considered to be finished , Bloodshy & Avant were persuaded by her A & R Teresa LaBarbera Whites to work on a new track . Winnberg commented that it had always been an unwritten rule not to write songs about Spears ' personal life since the label rejected " Sweet Dreams My LA Ex " , a response track to Justin Timberlake 's " Cry Me a River " . However , the duo wrote " Piece of Me " with Åhlund and sent it to Spears , who loved it . Bloodshy & Avant worked on the track at Bloodshy & Avant Studios in Stockholm , Sweden , and Spears recorded her vocals at Chalice Recording Studios in Los Angeles , California . Winnberg stated that Spears was extremely psyched when she came to the studio , where she recorded the song in about half an hour as she had learned the lyrics by heart in her car . " Piece of Me " was later mixed by Niklas Flyckt at <unk> Studios in Stockholm . On October 31 , 2007 , during a radio interview with Ryan Seacrest , Spears talked about the song , saying , 
