I've been down that road, and more than once...
First, make sure your window pane is positioned correctly in the front and rear window tracks. You'll have to remove the window from the sliding pivots and regulator in order to do so. It should slide up and down pretty easily, and stay in the tracks.
Once the window is "on track", snap the metal knobs back into the sliding pivots, and attach the metal pivot retaining clips. Give it a test to see if it works.
If this doesn't work, try adjusting the bolt that attaches the lower "back" arm to the door panel. It can be adjusted to move either up or down about 1/2 inch. This arm controls the angle at which the window slides up and down. Make sure your window is 3/4 of the way down when you do this adjustment. I'd recommend moving the arm up, to almost the highest position. Don't tighten it too much, or else it may give you problems.
The position of this arm has a lot to do with the window staying on track, and the sliding pivots staying in place.
If this still doesn't solve your problem, you may have bent the upper-back arm that attaches to the sliding pivots. If this appears to be the problem, try bending it (very very gently) so that it easily pops into the sliding pivot without much resistance. Make sure you re-attach the metal retaining clips to the pivots--Otherwise, the window might pop right out of the pivot again. I HATE that loud snapping sound!
Hope this helps. Best of luck!
-Mike