What kind of glue should I use for insulation to wood?
You want project adhesive. It's like construction adhesive, but water based. The solvent in "heavy duty" construction adhesive dissolves the foam, which probably resulted in the poor bond you experienced. Project adhesive labels often mention foam as a typical use. 

Be aware that water evaporates more slowly than solvents, and therefore your bonds require a longer cure time. 

Liquid Nails is a brand name. The company makes both products.