Rather than trying to fight the urge, you should try to understand why you have the urge in the first place. What is it about coding that makes you prefer doing it? And then, how can you mimic those conditions for all the "other stuff"?
In order to motivate myself to do the marketing type work, I had to connect a better feedback loop between that type of work, and my ultimate yardstick of success: revenue.
I did the same type of marketing you did for a while, and it was frustrating. You don't really know how/if/when your efforts are paying off. It feels like you're just grinding without any evident payoff.
So I pivoted a bit on my marketing project. I (we) completely changed our business model so that we see a clear progression from our marketing efforts to revenue. Basically, we started looking at page views instead of signing revenue sharing contracts, after a bit of a product pivot. This gave us lots of smaller feedback -- when you go a few weeks between checks coming in, things get tense... but when you're focused on page views, you have more frequent incremental improvement). We started looking at our logs more closely, and identified which sites had the better payoff for the least work.
In short, we did a few things differently, but it was just as important that we reframe the metric of success in our minds. Having that positive feedback loop is extremely important to morale. That's one thing I don't read much about on HN -- the importance of tying in the correct metrics to positive feedback loops, in order to keep your motivation up.