Clean the track that the gasket sat in using a mild soap and water, removing any debris or old glue residue with your fingers or with a plastic scraper.
Apply a thin line of adhesive around the track where the adhesive was. There are several kinds of adhesive you can use for this task. If an adhesive came with your new gasket, use that adhesive. You may also use glues such as super glue, Gorilla Glue and E6000 for this purpose.
Press the gasket into the track. The pressure as well as the glue will hold it there.
Clean up any spilled glue immediately using a damp cloth. For stubborn spots, apply a small amount acetone to loosen the glue.
Close the refrigerator door to hold the gasket to the track, and do not open it until the glue has cured. The amount of time needed for curing is referenced on the adhesive’s package.