I try to learn from my mistakes - like I was always slipping up and getting really yummy drinks from the drivethru. I decided to find out why I was doing it (convienience, they taste good, I am thirsty, I am bored/stresses/angry....) then I tried to find alternatives that would work for me. It's a trial and error process and you reallyl get to know yourself!
Another thing I found that it worked well for me when I was really struggling was reminding myself of my goal in the morning and before bed as well as during moments of temptation - if I can remind myself that the end goal is way more important than the immediate gratification of whatever - then I am not going to indulge (as often).
I still slip up, but I am getting there. Some months are better than others - I figure, that's just the way it is.