It just slides in.
It only goes in one way. If you have to force it, or if the slide rail segment that it represents does not match the rest of the rail, you're putting it in wrong.
Look at it, and the hole that accepts it, closely. The correct orientation will become obvious.
I have tried glue, cement, and epoxy resin. Nothing sticks.
You just have to be careful not to lose it, when you're cleaning the gun.
I sometimes catch it and set it aside, and sometimes I am just careful not to invert the frame while the slide is off.
I have only a slight idea of why they did it this way: The ejector had to be made of a stronger, denser plastic than that of the frame. But why couldn't it be pinned in place, or cast-in, or wedged in, or something—other than just left loose?