I recently solved this problem, yes 'solved' and it worked from day one. Thanks to Cal Newport's ideas.
The trick was this (YMMV, but I believe you sound exactly like me):
Imagine your mind like your desk. Every morning it's empty. (Usually) You wake up you load it up with all sorts of crap to entertain yourself, social media, Reddit, hacker news etc, etc.
By the time you get to work, there is no place to put work stuff on that desk. You try to put work stuff on it, but pretty much the whole desk is filled with Twitter/Tumblr/Facebook shit. So even if you make some space for the work stuff, sooner or later you focus on Tumblr again. Work stuff gets pushed out.
Generally in my case, by 2PM I manage to clear out all the distracting stuff and get focused.
The solution was this: BORE YOURSELF at every available opportunity.
When I start my morning, I refused to pick up my phone and check out social media (usually I would take a 45 minute dump just catching up on stuff posted last night). Sure my morning chores became a bit boring, but I also became more efficient (I started getting to work sooner).
Basically, by the time I get to my desk, I am so bored that the most interesting thing I can do is work. And my work (programming) is a very interesting task, it used to keep me engaged for hours and hours, it's just that Social Media defeated it.
I do check social media. I check it around 2PM after my standup. That 'impulsive' desire to constantly check it is gone. I catch up on all the social media in the evening or at night (but it doesn't create that compulsive pattern anymore.
End result: My productivity has gone up by 5-6 times. I have a performance enhancement story to work on and I managed to fix 6-7 bugs I found during my work, and it turns out that it was a whole team's sprint's work.