Toddler keeps popping in the floor instead of potty

She's 2 yrs old. She will take her diaper off by herself and I'll take her to the potty and tell her to go pee or poop. She will keep getting up and I'll try again. Do this several times before I give up and put her diaper back on. The minute nobody is looking she'll take the diaper off and poop in the floor. Any suggestions on what to do?