Use Past Perfect Continuous (had been + -ing) for actions that were ONGOING for a period of time BEFORE another past action or time. It emphasizes DURATION of an action that happened before something else in the past.
Practice tip: Ask: Was the action ONGOING before another past action? Did it continue for a period? Then use Past Perfect Continuous!