We used M&M's when my kids were little.
We started with our boys "making bubbles" in the toilet after watching me do it. My wife made a big deal of it and handed me some M&M's which she showed our sons as they watched me. (You cannot have a bashful bladder and do this.) She clapped her hands and made a big deal out of it.
It worked almost the same way with #2. Observe, reward, imitate. BTW, if they just pass gas, you reward them anyway because at the early stages they cannot tell the difference.
I have a large glass jar (probably 2.5 gallon size) filled with all kinds of fruit rollups, halloween sized candy and treats for my grand kids. I have more success in getting my grandkids to go to the bathroom than my kids do because of "Grandpa's special treats."
Good luck to you and yours.