I use a calorie/exercise tracking app, and I treat it as a game/challenge that I have to beat.
You set a goal weight and an amount you want to lose per week, and it calculates how many calories you're allowed per day based on that, your height, and your current weight. If you exercise more, you can eat more that day.
If you go over that amount, it turns red and has a negative sign and looks generally angry. But if you eat too little, it also gets mad. So, the challenge and the game is to stay within that sweet spot where the app isn't angry. If I blow it one day, I have to make up for it by staying in the green for the rest of the week and by exercising extra to counteract the overeating. Winning the game each week is avoiding red negative signs!
Wanting to keep my app from being mad at me has definitely kept me honest, even if it's a sign I'm perhaps too dependent on technology.
(In terms of exercise motivation beyond that, I concur with everyone who has said that you need to find an activity you enjoy. The gym itself can be pretty boring!)