glue
I have just finished laying a bunch of track on foam. I got some latex gloves and latex silicone caulk. I laid the track and used long pins to hold it in place. When all was fitted exactly, I used a marker along one side. I pulled some pins, laid a small bead of caulk, spread it thin with a gloved finger, and lay the track back down, and it is stuck. Make sure all joints are good. I have had to take some up later for changes and used a long cheap knife that slid under it and the track popped loose. Never had any trouble with it either. One tube of caulk will lay a heap of track. I laid over 100' with less than a 1/3 tube.
Lynn