Hello,
The secret to success is using the correct glue. I have used both the 3M weatherstrip adhesive and the Mercedes Brand weatherstrip adhesive. Both look the same and work well. They are both black in color and will look right after gluing. As with most contact cements both parts must be thoroughly cleaned before a coating is put onto both sides, then left to dry for the recommended time interval. It is important to clean the rubber also since the new rubber molding may have "mold release" compound on the gasket from the manufacturing process. Glue will not stick to it if so! I use plain old rubbing alcohol to remove oil and waxes from channels and rubber. Make sure that cleaning agents are gone before beginning.
Get some thin latex or gloves so you can use your finger to spread the glue on the rubber gasket. You will want to spread it on the all three glue sides of the gasket and channel so it really conforms to the groove. Don't try to work the whole gasket at once, do a section at a time. Yes, as advised, make sure the gasket is fitted first and in place as you are working on it so you do not stretch it and end up with too much gasket at the end of the job. I like to work on a section between two corners, gluing each corner in first, then the center of the run, then the rest. In this way the length of rubber is not stretched and always comes out correctly. It is not a 10 minute job. Most likely an hour or hour and a half. Have some solvent on hand which will not harm your paint for clean up. A nice plastic trim tool can help fit rubber. It takes a little practice to get the hang of it but things will start falling in place as you get going. Once in place and installed correctly it is watertight and stays in place.
Your local MB dealer can supply you with the MB Brand weatherstrip adhesive. The 3M Brand works as well (maybe the same) and is most likely a bit cheaper if you can find it.