Hartley came closed to scoring for Northampton in the second half but he was held up over the line as Saints failed to secure the four-try bonus point that would have boosted their hopes of advancing.
Jim Mallinder's side now have 14 points from their five games but leaders Ulster booked their progression with a comfortable victory over Glasgow Warriors.
As a result, Saints will most probably require a bonus point win when they travel to Glasgow next week, but Hartley admits the first priority is to secure the win.
"It shows we have a good character [to still be in the competition]," said Hartley.
"It was a good all-round performance. We wanted to score four tries and take five points but they are a good team and to close out a game as close as that was quite professional.
"Going into next week, we have to get five points to keep hopes alive. We are doing all right away from home. The spirit is good in the camp.
"All we can do is worry about winning and hopefully the tries will come with that."
Ulster's qualification came about thanks to a dogged 23-6 win over the Warriors after a Nick Williams try helped them into a 10-6 lead until the 55th minute when they cut loose and added scores from Jared Payne and Darren Cave.
Elsewhere, Sale Sharks could only muster two Danny Cipriani penalties as Montpellier claimed a bonus-point victory at the Salford City Stadium which took them level on points with pool leaders Toulon.
First-half scores from Yohann Artru and man-of-the-match Johnnie Beattie put the visitors in control despite Cipriani's two kicks and second half tries from Pierre Berard and a late penalty try sealed the five points.
With Sale already out of the competition, Steve Diamond opted to rest a number of first-team players but he pointed to the performance of Cipriani as a plus point from the night.
"I thought after the first scrum of the game we were in for a really hard night but they showed a lot of character," said the Sharks chief executive.
"There were a lot of positives moving forward into the league. It could have been a lot worse - we've got a lot out of it.
"A guy who takes a lot of the press generally who played well was Danny Cipriani. If he sticks to his kicking game for us he will be great.
"He keeps the forwards going. We were in the game at half-time because of Danny's kicking."
Meanwhile, in the Amlin Challenge Cup, Gloucester Rugby won a thrilling contest, 31-26 away to Bordeaux-Begles, largely thanks to England fly-half Freddie Burns.
Burns booted 26 points, including eight penalties and the conversion of Darren Dawidiuk's first-half try to seal the win and seal their place in the quarter-finals.
Trailing 20-19 at the break after scores from Rafael Carballo and Tamato Leupolu for the home side, Gloucester looked to be heading for their first defeat in the competition and found themselves 26-25 down with five minutes to go after two penalties from either side.
But Burns notched further three-pointers in the 75th and 80th minutes to send Gloucester through and in doing so, send London Irish out of the competition.
Heineken Cup
Northampton Saints 18 Castres 12
Northampton
Penalties: Myler 3, Lamb 3
Castres
Penalties: Kockott 4
Sale 6 Montpellier 27
Sale
Penalties: Cipriani 2
Montpellier
Tries: Paillaugue, Beattie, Berard, penalty
Conversions: Paillaugue, Escande
Penalties: Paillaugue
Ulster 23 Glasgow Warriors 6
Ulster
Tries: Williams, Payne, Cave
Conversions: Pienaar
Penalties: Pienaar 2
Glasgow Warriors
Penalties: Weir 2
AMLIN CHALLENGE CUP
Bordeaux-Begles 26 Gloucester Rugby 31
Bordeaux-Begles
Tries: Carballo, Leupolo
Conversions: Munro 2
Penalties: Munro 4
Gloucester Rugby
Tries: Dawidiuk
Conversions: Burns
Penalties: Burns 8