When you want to eat that treat and you know if you do you will regret it later: Log it in your food tracker, look through the calories and nutrition of your treat. Imagine how your treat tastes and feels in your mouth. Don't remove it from your log. Keep it there and go do something else. When you track your next meal or snack you will see it there and remember you never ate it. Either delete your treat or eat it then. Chances are the craving is gone and you can delete those empty calories!
I did this today. It was on accident. I logged a treat I was debating on eating. I got up from my computer to do the dishes before I made lunch and ended up eating a healthy lunch while forgetting about the treat until I logged my lunch and saw it there.