Two options:
1) If you have a suitable subroadbed (benachwork), you can nail the track. This requires plywood subroadbed, or homasote roadbed, or something similar that will hold nails.
2) Latex caulking. This holds very well, and the track can later be (carefully) pried off by slicing through the caulking with a metal putty knife. Just be sure that if you use this method to lay your track, that you use a MINIMAL amount of caulking - a very thin layer is all that's required. If it oozes up between the ties, you're using too much.
If you intend to do some scenery, or lay ballast on the track, be sure to use water soluable glue - like white glue. It can be softened where needed by laying a wet cloth over it to, which will loosen the glue so it can be scraped off.
Andrew