Staying truly productive throughout the day is not an easy task for most people. You have to fight two enemies: fatigue and distractions.
How to fight fatigue?
In the morning you can maintain your focus for a longer time, but as the day goes by your attention drifts away faster. Most people can't stay productive for longer than 30-45 minutes at a time. When you start noticing that you start looking for tasks to avoid the important job, such as checking your Facebook on you phone, immediately stop working. Don't waste your time pretending to be working. It's time to refresh your brain.
The reason you can't maintain focus for hours has physiological reasons. The brain drains blood sugar fast. You burn as much energy thinking as walking. When you are low on energy it becomes hard to keep on working. Also, when you sit for a long time your blood circulation slows down and in result the brain slows down too.
To fix this situation and reinvigorate your brain you need to stand up and do intense physical activity. This will increase the blood flow in your whole body including your brain. Your body will start to break down fat tissue reserves and release it into the blood in order to burn it off as fuel for your thinking. If you're really low on food you may also decide to snack a little. Foods that burn slowly are best to maintain long term concentration. Sugar highs and lows are not a good idea.
Do 20 pushups and 10 crouches or any other bodyweight exercises that fit your attire and office space.
How to fight distractions?
You can do your best creative work when you're in the 'flow'. Being in the zone is probably a familiar state of mind when you're completely absorbed in a task for extended periods of time.
Any distraction like a phone call or a co-worker chatting you up could bring you out of this precious condition. It could take 15-20 minutes to get back in, which is a waste of time and mental energy.
To fight distractions you simply have to put your phone into airplane mode (or do not disturb on iOS), go offline on chat, close your door or put a small sign on your table that says: Please Don't Disturb (Unless it's an Emergency).
How long can you do this?
With training you can get at least 3-4 sessions out of a day. But after that you have to give yourself a rest and move on to tasks that doesn't require intense concentration.
Do work related reading, clean up your to-do list, and do other mechanical tasks.
If you have other suggestions on how to stay productive do comment.