I'm considering lining all my tracks to near the outside in cage traps for added safety, but I'm wondering if building on them causes trouble somehow. Can you build them all right? Do the minecarts go over them smoothly, or do they just crash into them? Does it somehow trap the minecart? What about other types of traps?
I am not completely sure I understand what you want to do, but maybe you'll find all the answers you need at the df wiki entry on traps. To sum the important parts up:
They can be built indoors or outdoors, and require a level ground square with no other constructions in them.
This implies that you can't build tracks and traps on the same square. It seems you can build traps over tracks. And you can still designate a hauling route over your trapped path and this leads to
Stone-fall, weapon and cage traps will be triggered by most hostile entities entering their tileVerify, with the possible exception of thieves, flying creatures and other occasional nasty surprises. Any unconscious creature will trigger traps, including your own dwarves.
As I take it this means, that as long as your dwarves are conscious you won't have any problems. However, beware of cave-ins just on top of the traps, a falling dwarf might lose consciousness and thus trigger a trap.