The area of square BDFG is $6\times 6 = 36$ square units.

So the total area of the three triangles ABG, BCD and DEF is also $36$ square units.

These three triangles are congruent and so each has an area of $12$ square units.

The area of each triangle is $\frac{1}{2}\times base \times \ height$ and the base is $6$ units and hence we have $\frac{1}{2}\times 6 \times \ height = 12$,

so the height is $4$ units.

Let $X$ be the midpoint of BD. Then CX is perpendicular to the base BD (since BCD is an isosceles triangle).

By Pythagoras' Theorem, $BC = \sqrt{3^2+4^2} = 5$ units.

Therefore the perimeter of ABCDEFG is $6\times 5+ 6 = 36$ units.

*This problem is taken from the UKMT Mathematical Challenges.*