The in-form Terrors netted three second half goals after the teams reached half-time level at 1-1.
United only made certain of the three points with a brace of goals in the final six minutes and McNamara said: "I didn't think we were at our best but we still won.
"We said at half-time to keep our shape and discipline and we would get chances.
"That's how it turned out and we're delighted with the result in the end.
"It was more like a cup tie with tackles flying in which made it hard to get our momentum going.
"However, once we did we showed what we are capable of and got the goals we deserved.
"I'm pleased for Brian Graham. He is getting his rewards. He's had to be patient but is a confident player by nature which always helps.
"He took his header well and is always looking to get on the end of things."
His opposite number at Hearts, Gary Locke, added: "I thought we played well in the first half and were very much in the game.
"I've got to watch what I say but they got a free header inside the box for their second goal which was a vital moment.
"It was disappointing because Callum Paterson felt their player got a hold of his jersey before scoring.
"It was a decision which has gone against us.
"We were well-organised and battled hard. We didn't let our heads go down.
"Dundee United are a really good side and they are in sparkling form right now.
"I know 4-1 looks like we've taken another hammering but that's not the case.
"We went for it at 2-1 to try and get an equaliser but we got caught and Gary
Mackay-Steven hit a wonderful effort to make to make it 3-1."