Past perfect with FOR
The preposition for is used with the past perfect tense to express that something started before a point in time in the past and was still true at that point:
When they got married, they had already been together for three years.